{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "本章原文链接：https://usyiyi.github.io/nlp-py-2e-zh/3.html\n",
    "\n",
    "# 3 处理原始文本\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import nltk, re, pprint\n",
    "from nltk import word_tokenize"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3.1 从网络和硬盘访问文本"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1、从网络上下载文本"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'str'> \n",
      " 1176967 \n",
      "\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'\\ufeffThe Project Gutenberg EBook of Crime and Punishment, by Fyodor Dostoevsky\\r\\n\\r\\nTh'"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from urllib import request\n",
    "url = \"https://www.gutenberg.org/files/2554/2554-0.txt\"\n",
    "response = request.urlopen(url)\n",
    "raw = response.read().decode(\"utf8\")\n",
    "print(type(raw),\"\\n\", len(raw),\"\\n\")\n",
    "raw[:80]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2、分词"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'list'> \n",
      " 257727\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "['\\ufeffThe',\n",
       " 'Project',\n",
       " 'Gutenberg',\n",
       " 'EBook',\n",
       " 'of',\n",
       " 'Crime',\n",
       " 'and',\n",
       " 'Punishment',\n",
       " ',',\n",
       " 'by',\n",
       " 'Fyodor',\n",
       " 'Dostoevsky',\n",
       " 'This',\n",
       " 'eBook',\n",
       " 'is']"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tokens = word_tokenize(raw)\n",
    "print (type(tokens),\"\\n\",len(tokens))\n",
    "tokens[:15]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3、从这个列表创建一个NLTK 文本"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'nltk.text.Text'> \n",
      "\n",
      "['an', 'exceptionally', 'hot', 'evening', 'early', 'in', 'July', 'a', 'young', 'man', 'came', 'out', 'of', 'the', 'garret', 'in', 'which', 'he', 'lodged', 'in', 'S.', 'Place', 'and', 'walked', 'slowly', ',', 'as', 'though', 'in', 'hesitation', ',', 'towards', 'K.', 'bridge', '.', 'He', 'had', 'successfully'] \n",
      "\n",
      "Katerina Ivanovna; Pyotr Petrovitch; Pulcheria Alexandrovna; Avdotya\n",
      "Romanovna; Rodion Romanovitch; Marfa Petrovna; Sofya Semyonovna; old\n",
      "woman; Project Gutenberg-tm; Porfiry Petrovitch; Amalia Ivanovna;\n",
      "great deal; young man; Nikodim Fomitch; Ilya Petrovitch; Project\n",
      "Gutenberg; Andrey Semyonovitch; Hay Market; Dmitri Prokofitch; Good\n",
      "heavens\n"
     ]
    }
   ],
   "source": [
    "text = nltk.Text(tokens)\n",
    "print(type(text),\"\\n\")\n",
    "print(text[1024:1062],\"\\n\")\n",
    "text.collocations()                # 常用搭配"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 4、手工检查文件以发现标记内容开始和结尾的独特的字符串"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5336 \n",
      "\n",
      "1157812\n"
     ]
    }
   ],
   "source": [
    "print(raw.find(\"PART I\"),\"\\n\")\n",
    "print(raw.rfind(\"End of Project Gutenberg’s Crime\")) # 注意，这里的 ’  是中文符号下的 ‘    \n",
    "         # 这里的raw.rfind() 是反向find的意思"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'PART I\\r\\n\\r\\n\\r\\n\\r\\nCHAPTER I\\r\\n\\r\\nOn an exceptionally hot'"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "raw1 = raw[5336:1157812]\n",
    "raw1.find(\"PART I\")\n",
    "raw1[:50]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 5、处理HTML"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'<!doctype html public \"-//W3C//DTD HTML 4.0 Transitional//EN'"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "url = \"http://news.bbc.co.uk/2/hi/health/2284783.stm\"\n",
    "html = request.urlopen(url).read().decode(\"utf8\")\n",
    "html[:60]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['BBC',\n",
       " 'NEWS',\n",
       " '|',\n",
       " 'Health',\n",
       " '|',\n",
       " 'Blondes',\n",
       " \"'to\",\n",
       " 'die',\n",
       " 'out',\n",
       " 'in',\n",
       " '200',\n",
       " \"years'\",\n",
       " 'NEWS',\n",
       " 'SPORT',\n",
       " 'WEATHER',\n",
       " 'WORLD',\n",
       " 'SERVICE',\n",
       " 'A-Z',\n",
       " 'INDEX',\n",
       " 'SEARCH',\n",
       " 'You',\n",
       " 'are',\n",
       " 'in',\n",
       " ':',\n",
       " 'Health',\n",
       " 'News',\n",
       " 'Front',\n",
       " 'Page',\n",
       " 'Africa',\n",
       " 'Americas',\n",
       " 'Asia-Pacific',\n",
       " 'Europe',\n",
       " 'Middle',\n",
       " 'East',\n",
       " 'South',\n",
       " 'Asia',\n",
       " 'UK',\n",
       " 'Business',\n",
       " 'Entertainment',\n",
       " 'Science/Nature',\n",
       " 'Technology',\n",
       " 'Health',\n",
       " 'Medical',\n",
       " 'notes',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '-',\n",
       " 'Talking',\n",
       " 'Point',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '-',\n",
       " 'Country',\n",
       " 'Profiles',\n",
       " 'In',\n",
       " 'Depth',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '-',\n",
       " 'Programmes',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '-',\n",
       " 'SERVICES',\n",
       " 'Daily',\n",
       " 'E-mail',\n",
       " 'News',\n",
       " 'Ticker',\n",
       " 'Mobile/PDAs',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '-',\n",
       " 'Text',\n",
       " 'Only',\n",
       " 'Feedback',\n",
       " 'Help',\n",
       " 'EDITIONS',\n",
       " 'Change',\n",
       " 'to',\n",
       " 'UK',\n",
       " 'Friday',\n",
       " ',',\n",
       " '27',\n",
       " 'September',\n",
       " ',',\n",
       " '2002',\n",
       " ',',\n",
       " '11:51',\n",
       " 'GMT',\n",
       " '12:51',\n",
       " 'UK',\n",
       " 'Blondes',\n",
       " \"'to\",\n",
       " 'die',\n",
       " 'out',\n",
       " 'in',\n",
       " '200',\n",
       " \"years'\",\n",
       " 'Scientists',\n",
       " 'believe',\n",
       " 'the',\n",
       " 'last',\n",
       " 'blondes',\n",
       " 'will',\n",
       " 'be',\n",
       " 'in',\n",
       " 'Finland',\n",
       " 'The',\n",
       " 'last',\n",
       " 'natural',\n",
       " 'blondes',\n",
       " 'will',\n",
       " 'die',\n",
       " 'out',\n",
       " 'within',\n",
       " '200',\n",
       " 'years',\n",
       " ',',\n",
       " 'scientists',\n",
       " 'believe',\n",
       " '.',\n",
       " 'A',\n",
       " 'study',\n",
       " 'by',\n",
       " 'experts',\n",
       " 'in',\n",
       " 'Germany',\n",
       " 'suggests',\n",
       " 'people',\n",
       " 'with',\n",
       " 'blonde',\n",
       " 'hair',\n",
       " 'are',\n",
       " 'an',\n",
       " 'endangered',\n",
       " 'species',\n",
       " 'and',\n",
       " 'will',\n",
       " 'become',\n",
       " 'extinct',\n",
       " 'by',\n",
       " '2202',\n",
       " '.',\n",
       " 'Researchers',\n",
       " 'predict',\n",
       " 'the',\n",
       " 'last',\n",
       " 'truly',\n",
       " 'natural',\n",
       " 'blonde',\n",
       " 'will',\n",
       " 'be',\n",
       " 'born',\n",
       " 'in',\n",
       " 'Finland',\n",
       " '-',\n",
       " 'the',\n",
       " 'country',\n",
       " 'with',\n",
       " 'the',\n",
       " 'highest',\n",
       " 'proportion',\n",
       " 'of',\n",
       " 'blondes',\n",
       " '.',\n",
       " 'The',\n",
       " 'frequency',\n",
       " 'of',\n",
       " 'blondes',\n",
       " 'may',\n",
       " 'drop',\n",
       " 'but',\n",
       " 'they',\n",
       " 'wo',\n",
       " \"n't\",\n",
       " 'disappear',\n",
       " 'Prof',\n",
       " 'Jonathan',\n",
       " 'Rees',\n",
       " ',',\n",
       " 'University',\n",
       " 'of',\n",
       " 'Edinburgh',\n",
       " 'But',\n",
       " 'they',\n",
       " 'say',\n",
       " 'too',\n",
       " 'few',\n",
       " 'people',\n",
       " 'now',\n",
       " 'carry',\n",
       " 'the',\n",
       " 'gene',\n",
       " 'for',\n",
       " 'blondes',\n",
       " 'to',\n",
       " 'last',\n",
       " 'beyond',\n",
       " 'the',\n",
       " 'next',\n",
       " 'two',\n",
       " 'centuries',\n",
       " '.',\n",
       " 'The',\n",
       " 'problem',\n",
       " 'is',\n",
       " 'that',\n",
       " 'blonde',\n",
       " 'hair',\n",
       " 'is',\n",
       " 'caused',\n",
       " 'by',\n",
       " 'a',\n",
       " 'recessive',\n",
       " 'gene',\n",
       " '.',\n",
       " 'In',\n",
       " 'order',\n",
       " 'for',\n",
       " 'a',\n",
       " 'child',\n",
       " 'to',\n",
       " 'have',\n",
       " 'blonde',\n",
       " 'hair',\n",
       " ',',\n",
       " 'it',\n",
       " 'must',\n",
       " 'have',\n",
       " 'the',\n",
       " 'gene',\n",
       " 'on',\n",
       " 'both',\n",
       " 'sides',\n",
       " 'of',\n",
       " 'the',\n",
       " 'family',\n",
       " 'in',\n",
       " 'the',\n",
       " 'grandparents',\n",
       " \"'\",\n",
       " 'generation',\n",
       " '.',\n",
       " 'Dyed',\n",
       " 'rivals',\n",
       " 'The',\n",
       " 'researchers',\n",
       " 'also',\n",
       " 'believe',\n",
       " 'that',\n",
       " 'so-called',\n",
       " 'bottle',\n",
       " 'blondes',\n",
       " 'may',\n",
       " 'be',\n",
       " 'to',\n",
       " 'blame',\n",
       " 'for',\n",
       " 'the',\n",
       " 'demise',\n",
       " 'of',\n",
       " 'their',\n",
       " 'natural',\n",
       " 'rivals',\n",
       " '.',\n",
       " 'They',\n",
       " 'suggest',\n",
       " 'that',\n",
       " 'dyed-blondes',\n",
       " 'are',\n",
       " 'more',\n",
       " 'attractive',\n",
       " 'to',\n",
       " 'men',\n",
       " 'who',\n",
       " 'choose',\n",
       " 'them',\n",
       " 'as',\n",
       " 'partners',\n",
       " 'over',\n",
       " 'true',\n",
       " 'blondes',\n",
       " '.',\n",
       " 'Bottle-blondes',\n",
       " 'like',\n",
       " 'Ann',\n",
       " 'Widdecombe',\n",
       " 'may',\n",
       " 'be',\n",
       " 'to',\n",
       " 'blame',\n",
       " 'But',\n",
       " 'Jonathan',\n",
       " 'Rees',\n",
       " ',',\n",
       " 'professor',\n",
       " 'of',\n",
       " 'dermatology',\n",
       " 'at',\n",
       " 'the',\n",
       " 'University',\n",
       " 'of',\n",
       " 'Edinburgh',\n",
       " 'said',\n",
       " 'it',\n",
       " 'was',\n",
       " 'unlikely',\n",
       " 'blondes',\n",
       " 'would',\n",
       " 'die',\n",
       " 'out',\n",
       " 'completely',\n",
       " '.',\n",
       " '``',\n",
       " 'Genes',\n",
       " 'do',\n",
       " \"n't\",\n",
       " 'die',\n",
       " 'out',\n",
       " 'unless',\n",
       " 'there',\n",
       " 'is',\n",
       " 'a',\n",
       " 'disadvantage',\n",
       " 'of',\n",
       " 'having',\n",
       " 'that',\n",
       " 'gene',\n",
       " 'or',\n",
       " 'by',\n",
       " 'chance',\n",
       " '.',\n",
       " 'They',\n",
       " 'do',\n",
       " \"n't\",\n",
       " 'disappear',\n",
       " ',',\n",
       " \"''\",\n",
       " 'he',\n",
       " 'told',\n",
       " 'BBC',\n",
       " 'News',\n",
       " 'Online',\n",
       " '.',\n",
       " '``',\n",
       " 'The',\n",
       " 'only',\n",
       " 'reason',\n",
       " 'blondes',\n",
       " 'would',\n",
       " 'disappear',\n",
       " 'is',\n",
       " 'if',\n",
       " 'having',\n",
       " 'the',\n",
       " 'gene',\n",
       " 'was',\n",
       " 'a',\n",
       " 'disadvantage',\n",
       " 'and',\n",
       " 'I',\n",
       " 'do',\n",
       " 'not',\n",
       " 'think',\n",
       " 'that',\n",
       " 'is',\n",
       " 'the',\n",
       " 'case',\n",
       " '.',\n",
       " '``',\n",
       " 'The',\n",
       " 'frequency',\n",
       " 'of',\n",
       " 'blondes',\n",
       " 'may',\n",
       " 'drop',\n",
       " 'but',\n",
       " 'they',\n",
       " 'wo',\n",
       " \"n't\",\n",
       " 'disappear',\n",
       " '.',\n",
       " \"''\",\n",
       " 'See',\n",
       " 'also',\n",
       " ':',\n",
       " '28',\n",
       " 'Mar',\n",
       " '01',\n",
       " '|',\n",
       " 'Education',\n",
       " 'What',\n",
       " 'is',\n",
       " 'it',\n",
       " 'about',\n",
       " 'blondes',\n",
       " '?',\n",
       " '09',\n",
       " 'Apr',\n",
       " '99',\n",
       " '|',\n",
       " 'Health',\n",
       " 'Platinum',\n",
       " 'blondes',\n",
       " 'are',\n",
       " 'labelled',\n",
       " 'as',\n",
       " 'dumb',\n",
       " '17',\n",
       " 'Apr',\n",
       " '02',\n",
       " '|',\n",
       " 'Health',\n",
       " 'Hair',\n",
       " 'dye',\n",
       " 'cancer',\n",
       " 'alert',\n",
       " 'Internet',\n",
       " 'links',\n",
       " ':',\n",
       " 'University',\n",
       " 'of',\n",
       " 'Edinburgh',\n",
       " 'The',\n",
       " 'BBC',\n",
       " 'is',\n",
       " 'not',\n",
       " 'responsible',\n",
       " 'for',\n",
       " 'the',\n",
       " 'content',\n",
       " 'of',\n",
       " 'external',\n",
       " 'internet',\n",
       " 'sites',\n",
       " 'Top',\n",
       " 'Health',\n",
       " 'stories',\n",
       " 'now',\n",
       " ':',\n",
       " 'Heart',\n",
       " 'risk',\n",
       " 'link',\n",
       " 'to',\n",
       " 'big',\n",
       " 'families',\n",
       " 'Back',\n",
       " 'pain',\n",
       " 'drug',\n",
       " \"'may\",\n",
       " 'aid',\n",
       " \"diabetics'\",\n",
       " 'Congo',\n",
       " 'Ebola',\n",
       " 'outbreak',\n",
       " 'confirmed',\n",
       " 'Vegetables',\n",
       " 'ward',\n",
       " 'off',\n",
       " \"Alzheimer's\",\n",
       " 'Polio',\n",
       " 'campaign',\n",
       " 'launched',\n",
       " 'in',\n",
       " 'Iraq',\n",
       " 'Gene',\n",
       " 'defect',\n",
       " 'explains',\n",
       " 'high',\n",
       " 'blood',\n",
       " 'pressure',\n",
       " 'Botox',\n",
       " \"'may\",\n",
       " 'cause',\n",
       " 'new',\n",
       " \"wrinkles'\",\n",
       " 'Alien',\n",
       " \"'abductees\",\n",
       " \"'\",\n",
       " 'show',\n",
       " 'real',\n",
       " 'symptoms',\n",
       " 'Links',\n",
       " 'to',\n",
       " 'more',\n",
       " 'Health',\n",
       " 'stories',\n",
       " 'are',\n",
       " 'at',\n",
       " 'the',\n",
       " 'foot',\n",
       " 'of',\n",
       " 'the',\n",
       " 'page',\n",
       " '.',\n",
       " 'E-mail',\n",
       " 'this',\n",
       " 'story',\n",
       " 'to',\n",
       " 'a',\n",
       " 'friend',\n",
       " 'Links',\n",
       " 'to',\n",
       " 'more',\n",
       " 'Health',\n",
       " 'stories',\n",
       " 'In',\n",
       " 'This',\n",
       " 'Section',\n",
       " 'Heart',\n",
       " 'risk',\n",
       " 'link',\n",
       " 'to',\n",
       " 'big',\n",
       " 'families',\n",
       " 'Back',\n",
       " 'pain',\n",
       " 'drug',\n",
       " \"'may\",\n",
       " 'aid',\n",
       " \"diabetics'\",\n",
       " 'Congo',\n",
       " 'Ebola',\n",
       " 'outbreak',\n",
       " 'confirmed',\n",
       " 'Vegetables',\n",
       " 'ward',\n",
       " 'off',\n",
       " \"Alzheimer's\",\n",
       " 'Polio',\n",
       " 'campaign',\n",
       " 'launched',\n",
       " 'in',\n",
       " 'Iraq',\n",
       " 'Gene',\n",
       " 'defect',\n",
       " 'explains',\n",
       " 'high',\n",
       " 'blood',\n",
       " 'pressure',\n",
       " 'Botox',\n",
       " \"'may\",\n",
       " 'cause',\n",
       " 'new',\n",
       " \"wrinkles'\",\n",
       " 'Alien',\n",
       " \"'abductees\",\n",
       " \"'\",\n",
       " 'show',\n",
       " 'real',\n",
       " 'symptoms',\n",
       " 'How',\n",
       " 'sperm',\n",
       " 'wriggle',\n",
       " 'Bollywood',\n",
       " 'told',\n",
       " 'to',\n",
       " 'stub',\n",
       " 'it',\n",
       " 'out',\n",
       " 'Fears',\n",
       " 'over',\n",
       " 'tuna',\n",
       " 'health',\n",
       " 'risk',\n",
       " 'to',\n",
       " 'babies',\n",
       " 'Public',\n",
       " 'can',\n",
       " 'be',\n",
       " 'taught',\n",
       " 'to',\n",
       " 'spot',\n",
       " 'strokes',\n",
       " '^^',\n",
       " 'Back',\n",
       " 'to',\n",
       " 'top',\n",
       " 'News',\n",
       " 'Front',\n",
       " 'Page',\n",
       " '|',\n",
       " 'Africa',\n",
       " '|',\n",
       " 'Americas',\n",
       " '|',\n",
       " 'Asia-Pacific',\n",
       " '|',\n",
       " 'Europe',\n",
       " '|',\n",
       " 'Middle',\n",
       " 'East',\n",
       " '|',\n",
       " 'South',\n",
       " 'Asia',\n",
       " '|',\n",
       " 'UK',\n",
       " '|',\n",
       " 'Business',\n",
       " '|',\n",
       " 'Entertainment',\n",
       " '|',\n",
       " 'Science/Nature',\n",
       " '|',\n",
       " 'Technology',\n",
       " '|',\n",
       " 'Health',\n",
       " '|',\n",
       " 'Talking',\n",
       " 'Point',\n",
       " '|',\n",
       " 'Country',\n",
       " 'Profiles',\n",
       " '|',\n",
       " 'In',\n",
       " 'Depth',\n",
       " '|',\n",
       " 'Programmes',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " 'To',\n",
       " 'BBC',\n",
       " 'Sport',\n",
       " '>',\n",
       " '>',\n",
       " '|',\n",
       " 'To',\n",
       " 'BBC',\n",
       " 'Weather',\n",
       " '>',\n",
       " '>',\n",
       " '|',\n",
       " 'To',\n",
       " 'BBC',\n",
       " 'World',\n",
       " 'Service',\n",
       " '>',\n",
       " '>',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '--',\n",
       " '©',\n",
       " 'MMIII',\n",
       " '|',\n",
       " 'News',\n",
       " 'Sources',\n",
       " '|',\n",
       " 'Privacy',\n",
       " '<',\n",
       " '!',\n",
       " '--',\n",
       " 'var',\n",
       " 'pCid=',\n",
       " \"''\",\n",
       " 'uk_bbc_0',\n",
       " \"''\",\n",
       " ';',\n",
       " 'var',\n",
       " 'w0=1',\n",
       " ';',\n",
       " 'var',\n",
       " 'refR=escape',\n",
       " '(',\n",
       " 'document.referrer',\n",
       " ')',\n",
       " ';',\n",
       " 'if',\n",
       " '(',\n",
       " 'refR.length',\n",
       " '>',\n",
       " '=252',\n",
       " ')',\n",
       " 'refR=refR.substring',\n",
       " '(',\n",
       " '0,252',\n",
       " ')',\n",
       " '+',\n",
       " \"''\",\n",
       " '...',\n",
       " \"''\",\n",
       " ';',\n",
       " '//',\n",
       " '--',\n",
       " '>',\n",
       " '<',\n",
       " '!',\n",
       " '--',\n",
       " 'var',\n",
       " 'w0=0',\n",
       " ';',\n",
       " '//',\n",
       " '--',\n",
       " '>',\n",
       " '<',\n",
       " '!',\n",
       " '--',\n",
       " 'if',\n",
       " '(',\n",
       " 'w0',\n",
       " ')',\n",
       " '{',\n",
       " 'var',\n",
       " 'imgN=',\n",
       " \"'\",\n",
       " '<',\n",
       " 'img',\n",
       " 'src=',\n",
       " \"''\",\n",
       " 'http',\n",
       " ':',\n",
       " '//server-uk.imrworldwide.com/cgi-bin/count',\n",
       " '?',\n",
       " \"ref='+\",\n",
       " 'refR+',\n",
       " \"'\",\n",
       " '&',\n",
       " \"cid='+pCid+\",\n",
       " \"'\",\n",
       " \"''\",\n",
       " 'width=1',\n",
       " 'height=1',\n",
       " '>',\n",
       " \"'\",\n",
       " ';',\n",
       " 'if',\n",
       " '(',\n",
       " 'navigator.userAgent.indexOf',\n",
       " '(',\n",
       " \"'Mac\",\n",
       " \"'\",\n",
       " ')',\n",
       " '!',\n",
       " '=-1',\n",
       " ')',\n",
       " '{',\n",
       " 'document.write',\n",
       " '(',\n",
       " 'imgN',\n",
       " ')',\n",
       " ';',\n",
       " '}',\n",
       " 'else',\n",
       " '{',\n",
       " 'document.write',\n",
       " '(',\n",
       " \"'\",\n",
       " '<',\n",
       " 'applet',\n",
       " 'code=',\n",
       " \"''\",\n",
       " 'Measure.class',\n",
       " \"''\",\n",
       " \"'+\",\n",
       " \"'codebase=\",\n",
       " \"''\",\n",
       " 'http',\n",
       " ':',\n",
       " '//server-uk.imrworldwide.com/',\n",
       " \"''\",\n",
       " \"'+'width=1\",\n",
       " 'height=2',\n",
       " '>',\n",
       " \"'+\",\n",
       " \"'\",\n",
       " '<',\n",
       " 'param',\n",
       " 'name=',\n",
       " \"''\",\n",
       " 'ref',\n",
       " \"''\",\n",
       " 'value=',\n",
       " \"''\",\n",
       " \"'+refR+\",\n",
       " \"'\",\n",
       " \"''\",\n",
       " '>',\n",
       " \"'+\",\n",
       " \"'\",\n",
       " '<',\n",
       " 'param',\n",
       " 'name=',\n",
       " \"''\",\n",
       " 'cid',\n",
       " \"''\",\n",
       " 'value=',\n",
       " \"''\",\n",
       " \"'+pCid+\",\n",
       " \"'\",\n",
       " \"''\",\n",
       " '>',\n",
       " '<',\n",
       " 'textflow',\n",
       " '>',\n",
       " \"'+imgN+\",\n",
       " \"'\",\n",
       " '<',\n",
       " '/textflow',\n",
       " '>',\n",
       " '<',\n",
       " '/applet',\n",
       " '>',\n",
       " \"'\",\n",
       " ')',\n",
       " ';',\n",
       " '}',\n",
       " '}',\n",
       " 'document.write',\n",
       " '(',\n",
       " '``',\n",
       " '<',\n",
       " 'COMMENT',\n",
       " '>',\n",
       " \"''\",\n",
       " ')',\n",
       " ';',\n",
       " '//',\n",
       " '--',\n",
       " '>',\n",
       " '<',\n",
       " 'img',\n",
       " 'src=',\n",
       " \"''\",\n",
       " 'http',\n",
       " ':',\n",
       " '//server-uk.imrworldwide.com/cgi-bin/count',\n",
       " '?',\n",
       " 'cid=uk_bbc_0',\n",
       " \"''\",\n",
       " 'width=1',\n",
       " 'height=1',\n",
       " '>',\n",
       " 'var',\n",
       " 'si',\n",
       " '=',\n",
       " 'document.location+',\n",
       " \"''\",\n",
       " \"''\",\n",
       " ';',\n",
       " 'var',\n",
       " 'tsi',\n",
       " '=',\n",
       " 'si.replace',\n",
       " '(',\n",
       " '``',\n",
       " '.stm',\n",
       " \"''\",\n",
       " ',',\n",
       " \"''\",\n",
       " \"''\",\n",
       " ')',\n",
       " '.substr',\n",
       " '(',\n",
       " 'si.length-11',\n",
       " ',',\n",
       " 'si.length',\n",
       " ')',\n",
       " ';',\n",
       " 'if',\n",
       " '(',\n",
       " '!',\n",
       " 'tsi.match',\n",
       " '(',\n",
       " '/\\\\d\\\\d\\\\d\\\\d\\\\d\\\\d\\\\d/',\n",
       " ')',\n",
       " ')',\n",
       " '{',\n",
       " 'tsi',\n",
       " '=',\n",
       " '0',\n",
       " ';',\n",
       " '}',\n",
       " 'document.write',\n",
       " '(',\n",
       " \"'\",\n",
       " '<',\n",
       " 'img',\n",
       " 'src=',\n",
       " \"''\",\n",
       " 'http',\n",
       " ':',\n",
       " '//stats.bbc.co.uk/o.gif',\n",
       " '?',\n",
       " '~RS~s~RS~News~RS~t~RS~HighWeb_Legacy~RS~i~RS~',\n",
       " \"'\",\n",
       " '+',\n",
       " 'tsi',\n",
       " '+',\n",
       " \"'~RS~p~RS~0~RS~u~RS~/2/hi/health/2284783.stm~RS~r~RS~\",\n",
       " '(',\n",
       " 'none',\n",
       " ')',\n",
       " '~RS~a~RS~International~RS~q~RS~~RS~z~RS~19~RS~',\n",
       " \"''\",\n",
       " '>',\n",
       " \"'\",\n",
       " ')',\n",
       " ';',\n",
       " '<',\n",
       " 'img',\n",
       " 'src=',\n",
       " \"''\",\n",
       " 'http',\n",
       " ':',\n",
       " ...]"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from bs4 import BeautifulSoup\n",
    "raw = BeautifulSoup(html).get_text()\n",
    "tokens = word_tokenize(raw)\n",
    "tokens"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Displaying 5 of 5 matches:\n",
      "hey say too few people now carry the gene for blondes to last beyond the next \n",
      "blonde hair is caused by a recessive gene . In order for a child to have blond\n",
      " have blonde hair , it must have the gene on both sides of the family in the g\n",
      "ere is a disadvantage of having that gene or by chance . They do n't disappear\n",
      "des would disappear is if having the gene was a disadvantage and I do not thin\n"
     ]
    }
   ],
   "source": [
    "tokens = tokens[110:390]\n",
    "text = nltk.Text(tokens)\n",
    "text.concordance('gene')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 6、处理搜索引擎的结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'feed': {'title': '博客园_首页',\n",
       "  'title_detail': {'type': 'text/plain',\n",
       "   'language': None,\n",
       "   'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "   'value': '博客园_首页'},\n",
       "  'subtitle': '代码改变世界',\n",
       "  'subtitle_detail': {'type': 'text/plain',\n",
       "   'language': None,\n",
       "   'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "   'value': '代码改变世界'},\n",
       "  'id': 'uuid:386a934f-6ca4-419e-8428-9296c17f29e8;id=472199',\n",
       "  'guidislink': True,\n",
       "  'link': 'uuid:386a934f-6ca4-419e-8428-9296c17f29e8;id=472199',\n",
       "  'updated': '2019-04-25T07:09:08Z',\n",
       "  'updated_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=7, tm_min=9, tm_sec=8, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "  'generator_detail': {'name': 'feed.cnblogs.com'},\n",
       "  'generator': 'feed.cnblogs.com'},\n",
       " 'entries': [{'id': 'http://www.cnblogs.com/MrHSR/p/10766590.html',\n",
       "   'guidislink': True,\n",
       "   'link': 'http://www.cnblogs.com/MrHSR/p/10766590.html',\n",
       "   'title': 'asp.net core系列 60 Ocelot 构建服务认证示例 - 花阴偷移',\n",
       "   'title_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': 'asp.net core系列 60 Ocelot 构建服务认证示例 - 花阴偷移'},\n",
       "   'summary': '一.概述 在Ocelot中，为了保护下游api资源，用户访问时需要进行认证鉴权，这需要在Ocelot\\xa0网关中添加认证服务。添加认证后，ReRoutes路由会进行身份验证,并使用Ocelot的基于声明的功能。在Startup.cs中注册认证服务，为每个注册提供一个方案 (authenticationP',\n",
       "   'summary_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': '一.概述 在Ocelot中，为了保护下游api资源，用户访问时需要进行认证鉴权，这需要在Ocelot\\xa0网关中添加认证服务。添加认证后，ReRoutes路由会进行身份验证,并使用Ocelot的基于声明的功能。在Startup.cs中注册认证服务，为每个注册提供一个方案 (authenticationP'},\n",
       "   'published': '2019-04-25T07:06:00Z',\n",
       "   'published_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=7, tm_min=6, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'updated': '2019-04-25T07:06:00Z',\n",
       "   'updated_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=7, tm_min=6, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'authors': [{'name': '花阴偷移', 'href': 'http://www.cnblogs.com/MrHSR/'}],\n",
       "   'author_detail': {'name': '花阴偷移', 'href': 'http://www.cnblogs.com/MrHSR/'},\n",
       "   'href': 'http://www.cnblogs.com/MrHSR/',\n",
       "   'author': '花阴偷移',\n",
       "   'links': [{'rel': 'alternate',\n",
       "     'href': 'http://www.cnblogs.com/MrHSR/p/10766590.html',\n",
       "     'type': 'text/html'},\n",
       "    {'rel': 'alternate',\n",
       "     'type': 'text/html',\n",
       "     'href': 'http://www.cnblogs.com/MrHSR/p/10766590.html'}],\n",
       "   'content': [{'type': 'text/html',\n",
       "     'language': None,\n",
       "     'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "     'value': '【摘要】一.概述 在Ocelot中，为了保护下游api资源，用户访问时需要进行认证鉴权，这需要在Ocelot\\xa0网关中添加认证服务。添加认证后，ReRoutes路由会进行身份验证,并使用Ocelot的基于声明的功能。在Startup.cs中注册认证服务，为每个注册提供一个方案 (authenticationP <a href=\"http://www.cnblogs.com/MrHSR/p/10766590.html\" target=\"_blank\">阅读全文</a>'}]},\n",
       "  {'id': 'http://www.cnblogs.com/lidengfeng/p/10768474.html',\n",
       "   'guidislink': True,\n",
       "   'link': 'http://www.cnblogs.com/lidengfeng/p/10768474.html',\n",
       "   'title': 'Vue2.0源码阅读笔记（三）：计算属性 - 雾雪天涯',\n",
       "   'title_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': 'Vue2.0源码阅读笔记（三）：计算属性 - 雾雪天涯'},\n",
       "   'summary': '计算属性是基于响应式依赖进行缓存的，只有在相关响应式依赖发生改变时才会重新求值，这种缓存机制在求值消耗比较大的情况下能够显著提高性能。 一、计算属性初始化 \\u2003Vue 在做数据初始化时，通过 initComputed() 方法初始化计算属性。 js con',\n",
       "   'summary_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': '计算属性是基于响应式依赖进行缓存的，只有在相关响应式依赖发生改变时才会重新求值，这种缓存机制在求值消耗比较大的情况下能够显著提高性能。 一、计算属性初始化 \\u2003Vue 在做数据初始化时，通过 initComputed() 方法初始化计算属性。 js con'},\n",
       "   'published': '2019-04-25T07:00:00Z',\n",
       "   'published_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=7, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'updated': '2019-04-25T07:00:00Z',\n",
       "   'updated_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=7, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'authors': [{'name': '雾雪天涯', 'href': 'http://www.cnblogs.com/lidengfeng/'}],\n",
       "   'author_detail': {'name': '雾雪天涯',\n",
       "    'href': 'http://www.cnblogs.com/lidengfeng/'},\n",
       "   'href': 'http://www.cnblogs.com/lidengfeng/',\n",
       "   'author': '雾雪天涯',\n",
       "   'links': [{'rel': 'alternate',\n",
       "     'href': 'http://www.cnblogs.com/lidengfeng/p/10768474.html',\n",
       "     'type': 'text/html'},\n",
       "    {'rel': 'alternate',\n",
       "     'type': 'text/html',\n",
       "     'href': 'http://www.cnblogs.com/lidengfeng/p/10768474.html'}],\n",
       "   'content': [{'type': 'text/html',\n",
       "     'language': None,\n",
       "     'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "     'value': '【摘要】 计算属性是基于响应式依赖进行缓存的，只有在相关响应式依赖发生改变时才会重新求值，这种缓存机制在求值消耗比较大的情况下能够显著提高性能。 一、计算属性初始化 \\u2003Vue 在做数据初始化时，通过 initComputed() 方法初始化计算属性。 js con <a href=\"http://www.cnblogs.com/lidengfeng/p/10768474.html\" target=\"_blank\">阅读全文</a>'}]},\n",
       "  {'id': 'http://www.cnblogs.com/gavinjay/p/10768378.html',\n",
       "   'guidislink': True,\n",
       "   'link': 'http://www.cnblogs.com/gavinjay/p/10768378.html',\n",
       "   'title': 'KnockOut 绑定之foreach绑定 - GavinJay',\n",
       "   'title_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': 'KnockOut 绑定之foreach绑定 - GavinJay'},\n",
       "   'summary': 'foreach绑定对于数组中的每一个元素复制一节标记语言，也就是html，并且将这节标记语言和数组里面的每一个元素绑定。当我们呈现一组list数据，或者一个表格的时候，十分有用。 如果你绑定的数组是一个\"监控数组\"\\xa0,observable array,(和wpf里面的ObservableCollec',\n",
       "   'summary_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': 'foreach绑定对于数组中的每一个元素复制一节标记语言，也就是html，并且将这节标记语言和数组里面的每一个元素绑定。当我们呈现一组list数据，或者一个表格的时候，十分有用。 如果你绑定的数组是一个\"监控数组\"\\xa0,observable array,(和wpf里面的ObservableCollec'},\n",
       "   'published': '2019-04-25T06:47:00Z',\n",
       "   'published_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=6, tm_min=47, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'updated': '2019-04-25T06:47:00Z',\n",
       "   'updated_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=6, tm_min=47, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'authors': [{'name': 'GavinJay',\n",
       "     'href': 'http://www.cnblogs.com/gavinjay/'}],\n",
       "   'author_detail': {'name': 'GavinJay',\n",
       "    'href': 'http://www.cnblogs.com/gavinjay/'},\n",
       "   'href': 'http://www.cnblogs.com/gavinjay/',\n",
       "   'author': 'GavinJay',\n",
       "   'links': [{'rel': 'alternate',\n",
       "     'href': 'http://www.cnblogs.com/gavinjay/p/10768378.html',\n",
       "     'type': 'text/html'},\n",
       "    {'rel': 'alternate',\n",
       "     'type': 'text/html',\n",
       "     'href': 'http://www.cnblogs.com/gavinjay/p/10768378.html'}],\n",
       "   'content': [{'type': 'text/html',\n",
       "     'language': None,\n",
       "     'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "     'value': '【摘要】foreach绑定对于数组中的每一个元素复制一节标记语言，也就是html，并且将这节标记语言和数组里面的每一个元素绑定。当我们呈现一组list数据，或者一个表格的时候，十分有用。 如果你绑定的数组是一个\"监控数组\"\\xa0,observable array,(和wpf里面的ObservableCollec <a href=\"http://www.cnblogs.com/gavinjay/p/10768378.html\" target=\"_blank\">阅读全文</a>'}]},\n",
       "  {'id': 'http://www.cnblogs.com/zhangnan35/p/10709876.html',\n",
       "   'guidislink': True,\n",
       "   'link': 'http://www.cnblogs.com/zhangnan35/p/10709876.html',\n",
       "   'title': '从css 3d说到空间坐标轴 - 陌上兮月',\n",
       "   'title_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': '从css 3d说到空间坐标轴 - 陌上兮月'},\n",
       "   'summary': '有一次我们说到掷骰子那个游戏，当时是用了一个steps属性+雪碧图来制作帧动画，这当然颇为不错，但其实一开始我想的不是这样的，我想的是用真的3d和动画去做，这个方案涉及到不少空间的知识，今天来给大伙好好说说，这css 3d到底怎么玩。 先上效果图： 基本思路：三层结构：视角容器>>载体>>具体3d图',\n",
       "   'summary_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': '有一次我们说到掷骰子那个游戏，当时是用了一个steps属性+雪碧图来制作帧动画，这当然颇为不错，但其实一开始我想的不是这样的，我想的是用真的3d和动画去做，这个方案涉及到不少空间的知识，今天来给大伙好好说说，这css 3d到底怎么玩。 先上效果图： 基本思路：三层结构：视角容器>>载体>>具体3d图'},\n",
       "   'published': '2019-04-25T06:39:00Z',\n",
       "   'published_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=6, tm_min=39, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'updated': '2019-04-25T06:39:00Z',\n",
       "   'updated_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=6, tm_min=39, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'authors': [{'name': '陌上兮月', 'href': 'http://www.cnblogs.com/zhangnan35/'}],\n",
       "   'author_detail': {'name': '陌上兮月',\n",
       "    'href': 'http://www.cnblogs.com/zhangnan35/'},\n",
       "   'href': 'http://www.cnblogs.com/zhangnan35/',\n",
       "   'author': '陌上兮月',\n",
       "   'links': [{'rel': 'alternate',\n",
       "     'href': 'http://www.cnblogs.com/zhangnan35/p/10709876.html',\n",
       "     'type': 'text/html'},\n",
       "    {'rel': 'alternate',\n",
       "     'type': 'text/html',\n",
       "     'href': 'http://www.cnblogs.com/zhangnan35/p/10709876.html'}],\n",
       "   'content': [{'type': 'text/html',\n",
       "     'language': None,\n",
       "     'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "     'value': '【摘要】有一次我们说到掷骰子那个游戏，当时是用了一个steps属性+雪碧图来制作帧动画，这当然颇为不错，但其实一开始我想的不是这样的，我想的是用真的3d和动画去做，这个方案涉及到不少空间的知识，今天来给大伙好好说说，这css 3d到底怎么玩。 先上效果图： 基本思路：三层结构：视角容器>>载体>>具体3d图 <a href=\"http://www.cnblogs.com/zhangnan35/p/10709876.html\" target=\"_blank\">阅读全文</a>'}]},\n",
       "  {'id': 'http://www.cnblogs.com/stall/p/10768299.html',\n",
       "   'guidislink': True,\n",
       "   'link': 'http://www.cnblogs.com/stall/p/10768299.html',\n",
       "   'title': 'android渠道打包怎样实现最方便 - 往昔是少年',\n",
       "   'title_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': 'android渠道打包怎样实现最方便 - 往昔是少年'},\n",
       "   'summary': '我们都知道，Android 市场被分割成几十个应用商店渠道，程序员给渠道打包、更新是一件异常繁杂又不得不做的工作，但现在有一种快捷灵活的免费多渠道统计方式，能最大程度的提高打包效率和数据安全性。 首先登录openinstall\\xa0官网，下载Android SDK，一般5-10分钟可以集成完成，非常简单',\n",
       "   'summary_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': '我们都知道，Android 市场被分割成几十个应用商店渠道，程序员给渠道打包、更新是一件异常繁杂又不得不做的工作，但现在有一种快捷灵活的免费多渠道统计方式，能最大程度的提高打包效率和数据安全性。 首先登录openinstall\\xa0官网，下载Android SDK，一般5-10分钟可以集成完成，非常简单'},\n",
       "   'published': '2019-04-25T06:35:00Z',\n",
       "   'published_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=6, tm_min=35, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'updated': '2019-04-25T06:35:00Z',\n",
       "   'updated_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=6, tm_min=35, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'authors': [{'name': '往昔是少年', 'href': 'http://www.cnblogs.com/stall/'}],\n",
       "   'author_detail': {'name': '往昔是少年', 'href': 'http://www.cnblogs.com/stall/'},\n",
       "   'href': 'http://www.cnblogs.com/stall/',\n",
       "   'author': '往昔是少年',\n",
       "   'links': [{'rel': 'alternate',\n",
       "     'href': 'http://www.cnblogs.com/stall/p/10768299.html',\n",
       "     'type': 'text/html'},\n",
       "    {'rel': 'alternate',\n",
       "     'type': 'text/html',\n",
       "     'href': 'http://www.cnblogs.com/stall/p/10768299.html'}],\n",
       "   'content': [{'type': 'text/html',\n",
       "     'language': None,\n",
       "     'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "     'value': '【摘要】我们都知道，Android 市场被分割成几十个应用商店渠道，程序员给渠道打包、更新是一件异常繁杂又不得不做的工作，但现在有一种快捷灵活的免费多渠道统计方式，能最大程度的提高打包效率和数据安全性。 首先登录openinstall\\xa0官网，下载Android SDK，一般5-10分钟可以集成完成，非常简单 <a href=\"http://www.cnblogs.com/stall/p/10768299.html\" target=\"_blank\">阅读全文</a>'}]},\n",
       "  {'id': 'http://www.cnblogs.com/zfcode/p/mu-biao-jian-ce-anchor-li-jie-bi-ji.html',\n",
       "   'guidislink': True,\n",
       "   'link': 'http://www.cnblogs.com/zfcode/p/mu-biao-jian-ce-anchor-li-jie-bi-ji.html',\n",
       "   'title': '目标检测 anchor 理解笔记 - zfCode',\n",
       "   'title_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': '目标检测 anchor 理解笔记 - zfCode'},\n",
       "   'summary': 'anchor在计算机视觉中有锚点或锚框，目标检测中常出现的anchor box是锚框，表示固定的参考框。目标检测的任务：在哪里有东西难点：目标的类别不确定、数量不确定、位置不确定、尺度不确定传统算法的解决方式：都要金字塔多尺度+遍历滑窗的方式，逐尺度逐位置判断\"这个尺度的这个位置处有没有认识的目标\"...',\n",
       "   'summary_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': 'anchor在计算机视觉中有锚点或锚框，目标检测中常出现的anchor box是锚框，表示固定的参考框。目标检测的任务：在哪里有东西难点：目标的类别不确定、数量不确定、位置不确定、尺度不确定传统算法的解决方式：都要金字塔多尺度+遍历滑窗的方式，逐尺度逐位置判断\"这个尺度的这个位置处有没有认识的目标\"...'},\n",
       "   'published': '2019-04-25T06:17:00Z',\n",
       "   'published_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=6, tm_min=17, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'updated': '2019-04-25T06:17:00Z',\n",
       "   'updated_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=6, tm_min=17, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'authors': [{'name': 'zfCode', 'href': 'http://www.cnblogs.com/zfcode/'}],\n",
       "   'author_detail': {'name': 'zfCode',\n",
       "    'href': 'http://www.cnblogs.com/zfcode/'},\n",
       "   'href': 'http://www.cnblogs.com/zfcode/',\n",
       "   'author': 'zfCode',\n",
       "   'links': [{'rel': 'alternate',\n",
       "     'href': 'http://www.cnblogs.com/zfcode/p/mu-biao-jian-ce-anchor-li-jie-bi-ji.html',\n",
       "     'type': 'text/html'},\n",
       "    {'rel': 'alternate',\n",
       "     'type': 'text/html',\n",
       "     'href': 'http://www.cnblogs.com/zfcode/p/mu-biao-jian-ce-anchor-li-jie-bi-ji.html'}],\n",
       "   'content': [{'type': 'text/html',\n",
       "     'language': None,\n",
       "     'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "     'value': '【摘要】anchor在计算机视觉中有锚点或锚框，目标检测中常出现的anchor box是锚框，表示固定的参考框。目标检测的任务：在哪里有东西难点：目标的类别不确定、数量不确定、位置不确定、尺度不确定传统算法的解决方式：都要金字塔多尺度+遍历滑窗的方式，逐尺度逐位置判断\"这个尺度的这个位置处有没有认识的目标\"... <a href=\"http://www.cnblogs.com/zfcode/p/mu-biao-jian-ce-anchor-li-jie-bi-ji.html\" target=\"_blank\">阅读全文</a>'}]},\n",
       "  {'id': 'http://www.cnblogs.com/justlikeheaven/p/myisam-lock.html',\n",
       "   'guidislink': True,\n",
       "   'link': 'http://www.cnblogs.com/justlikeheaven/p/myisam-lock.html',\n",
       "   'title': 'MyISAM加锁分析 - pigfly',\n",
       "   'title_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': 'MyISAM加锁分析 - pigfly'},\n",
       "   'summary': '为什么加锁 你正在读着你喜欢的女孩递给你的信，看到一半的时候，她的好闺蜜过来瞄了一眼（假设她会隐身术，你看不到她），她想把“我很喜欢你”改成“我不喜欢你”，刚把“很”字擦掉，“不”字还没写完，只写了一横一撇，这时候你正读到这个字，她怕你察觉到也就没继续往下写了，这时候你读到的这句话就是“我丆喜欢你”',\n",
       "   'summary_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': '为什么加锁 你正在读着你喜欢的女孩递给你的信，看到一半的时候，她的好闺蜜过来瞄了一眼（假设她会隐身术，你看不到她），她想把“我很喜欢你”改成“我不喜欢你”，刚把“很”字擦掉，“不”字还没写完，只写了一横一撇，这时候你正读到这个字，她怕你察觉到也就没继续往下写了，这时候你读到的这句话就是“我丆喜欢你”'},\n",
       "   'published': '2019-04-25T06:09:00Z',\n",
       "   'published_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=6, tm_min=9, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'updated': '2019-04-25T06:09:00Z',\n",
       "   'updated_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=6, tm_min=9, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'authors': [{'name': 'pigfly',\n",
       "     'href': 'http://www.cnblogs.com/justlikeheaven/'}],\n",
       "   'author_detail': {'name': 'pigfly',\n",
       "    'href': 'http://www.cnblogs.com/justlikeheaven/'},\n",
       "   'href': 'http://www.cnblogs.com/justlikeheaven/',\n",
       "   'author': 'pigfly',\n",
       "   'links': [{'rel': 'alternate',\n",
       "     'href': 'http://www.cnblogs.com/justlikeheaven/p/myisam-lock.html',\n",
       "     'type': 'text/html'},\n",
       "    {'rel': 'alternate',\n",
       "     'type': 'text/html',\n",
       "     'href': 'http://www.cnblogs.com/justlikeheaven/p/myisam-lock.html'}],\n",
       "   'content': [{'type': 'text/html',\n",
       "     'language': None,\n",
       "     'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "     'value': '【摘要】为什么加锁 你正在读着你喜欢的女孩递给你的信，看到一半的时候，她的好闺蜜过来瞄了一眼（假设她会隐身术，你看不到她），她想把“我很喜欢你”改成“我不喜欢你”，刚把“很”字擦掉，“不”字还没写完，只写了一横一撇，这时候你正读到这个字，她怕你察觉到也就没继续往下写了，这时候你读到的这句话就是“我丆喜欢你” <a href=\"http://www.cnblogs.com/justlikeheaven/p/myisam-lock.html\" target=\"_blank\">阅读全文</a>'}]},\n",
       "  {'id': 'http://www.cnblogs.com/ityouknow/p/10768105.html',\n",
       "   'guidislink': True,\n",
       "   'link': 'http://www.cnblogs.com/ityouknow/p/10768105.html',\n",
       "   'title': '做一个有脑子的程序员 - 纯洁的微笑',\n",
       "   'title_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': '做一个有脑子的程序员 - 纯洁的微笑'},\n",
       "   'summary': '程序员是最理性的一个群人，除非面对电子产品的时。 程序员是一群高智商的群体，唯一的缺点就是发际线总是很难防守。 程序员是一群情商比较低的人群，常常看到程序员仅仅因为对技术的理解不同而大吵起来。 程序员常常是一群豁达的人，今天大吵一架明天接着聊代码。 但今天要讨论的却是，做一个有脑子的程序员。 有一个',\n",
       "   'summary_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': '程序员是最理性的一个群人，除非面对电子产品的时。 程序员是一群高智商的群体，唯一的缺点就是发际线总是很难防守。 程序员是一群情商比较低的人群，常常看到程序员仅仅因为对技术的理解不同而大吵起来。 程序员常常是一群豁达的人，今天大吵一架明天接着聊代码。 但今天要讨论的却是，做一个有脑子的程序员。 有一个'},\n",
       "   'published': '2019-04-25T06:06:00Z',\n",
       "   'published_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=6, tm_min=6, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'updated': '2019-04-25T06:06:00Z',\n",
       "   'updated_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=6, tm_min=6, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'authors': [{'name': '纯洁的微笑', 'href': 'http://www.cnblogs.com/ityouknow/'}],\n",
       "   'author_detail': {'name': '纯洁的微笑',\n",
       "    'href': 'http://www.cnblogs.com/ityouknow/'},\n",
       "   'href': 'http://www.cnblogs.com/ityouknow/',\n",
       "   'author': '纯洁的微笑',\n",
       "   'links': [{'rel': 'alternate',\n",
       "     'href': 'http://www.cnblogs.com/ityouknow/p/10768105.html',\n",
       "     'type': 'text/html'},\n",
       "    {'rel': 'alternate',\n",
       "     'type': 'text/html',\n",
       "     'href': 'http://www.cnblogs.com/ityouknow/p/10768105.html'}],\n",
       "   'content': [{'type': 'text/html',\n",
       "     'language': None,\n",
       "     'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "     'value': '【摘要】程序员是最理性的一个群人，除非面对电子产品的时。 程序员是一群高智商的群体，唯一的缺点就是发际线总是很难防守。 程序员是一群情商比较低的人群，常常看到程序员仅仅因为对技术的理解不同而大吵起来。 程序员常常是一群豁达的人，今天大吵一架明天接着聊代码。 但今天要讨论的却是，做一个有脑子的程序员。 有一个 <a href=\"http://www.cnblogs.com/ityouknow/p/10768105.html\" target=\"_blank\">阅读全文</a>'}]},\n",
       "  {'id': 'http://www.cnblogs.com/aaron---blog/p/10768037.html',\n",
       "   'guidislink': True,\n",
       "   'link': 'http://www.cnblogs.com/aaron---blog/p/10768037.html',\n",
       "   'title': '网络编程-(理论篇) - Aaron-攻城狮',\n",
       "   'title_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': '网络编程-(理论篇) - Aaron-攻城狮'},\n",
       "   'summary': '对于初学者，或者没有接触过网络编程的程序员，会觉得网络编程涉及的知识很高深，很难，其实这是一种误解，当你的语法熟悉以后，其实基本的网络编程现在已经被实现的异常简单了。 网络通信作为互联网的技术支持，已被广泛应用在软件开发中，无论是Web，服务端，客户端还是桌面应用，都是必须掌握的一门技术。 网络编程',\n",
       "   'summary_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': '对于初学者，或者没有接触过网络编程的程序员，会觉得网络编程涉及的知识很高深，很难，其实这是一种误解，当你的语法熟悉以后，其实基本的网络编程现在已经被实现的异常简单了。 网络通信作为互联网的技术支持，已被广泛应用在软件开发中，无论是Web，服务端，客户端还是桌面应用，都是必须掌握的一门技术。 网络编程'},\n",
       "   'published': '2019-04-25T05:57:00Z',\n",
       "   'published_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=5, tm_min=57, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'updated': '2019-04-25T05:57:00Z',\n",
       "   'updated_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=5, tm_min=57, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'authors': [{'name': 'Aaron-攻城狮',\n",
       "     'href': 'http://www.cnblogs.com/aaron---blog/'}],\n",
       "   'author_detail': {'name': 'Aaron-攻城狮',\n",
       "    'href': 'http://www.cnblogs.com/aaron---blog/'},\n",
       "   'href': 'http://www.cnblogs.com/aaron---blog/',\n",
       "   'author': 'Aaron-攻城狮',\n",
       "   'links': [{'rel': 'alternate',\n",
       "     'href': 'http://www.cnblogs.com/aaron---blog/p/10768037.html',\n",
       "     'type': 'text/html'},\n",
       "    {'rel': 'alternate',\n",
       "     'type': 'text/html',\n",
       "     'href': 'http://www.cnblogs.com/aaron---blog/p/10768037.html'}],\n",
       "   'content': [{'type': 'text/html',\n",
       "     'language': None,\n",
       "     'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "     'value': '【摘要】对于初学者，或者没有接触过网络编程的程序员，会觉得网络编程涉及的知识很高深，很难，其实这是一种误解，当你的语法熟悉以后，其实基本的网络编程现在已经被实现的异常简单了。 网络通信作为互联网的技术支持，已被广泛应用在软件开发中，无论是Web，服务端，客户端还是桌面应用，都是必须掌握的一门技术。 网络编程 <a href=\"http://www.cnblogs.com/aaron---blog/p/10768037.html\" target=\"_blank\">阅读全文</a>'}]},\n",
       "  {'id': 'http://www.cnblogs.com/yilezhu/p/10767910.html',\n",
       "   'guidislink': True,\n",
       "   'link': 'http://www.cnblogs.com/yilezhu/p/10767910.html',\n",
       "   'title': '分享一个.NET平台开源免费跨平台的大数据分析框架.NET for Apache Spark - 依乐祝',\n",
       "   'title_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': '分享一个.NET平台开源免费跨平台的大数据分析框架.NET for Apache Spark - 依乐祝'},\n",
       "   'summary': '今天早上六点半左右微信群里就看到张队发的关于.NET Spark大数据的链接https://devblogs.microsoft.com/dotnet/introducing net for apache spark/ ，正印证了“微软在不断通过.NET Core补齐各领域开发，真正实现一种语言的跨',\n",
       "   'summary_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': '今天早上六点半左右微信群里就看到张队发的关于.NET Spark大数据的链接https://devblogs.microsoft.com/dotnet/introducing net for apache spark/ ，正印证了“微软在不断通过.NET Core补齐各领域开发，真正实现一种语言的跨'},\n",
       "   'published': '2019-04-25T05:33:00Z',\n",
       "   'published_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=5, tm_min=33, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'updated': '2019-04-25T05:33:00Z',\n",
       "   'updated_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=5, tm_min=33, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'authors': [{'name': '依乐祝', 'href': 'http://www.cnblogs.com/yilezhu/'}],\n",
       "   'author_detail': {'name': '依乐祝', 'href': 'http://www.cnblogs.com/yilezhu/'},\n",
       "   'href': 'http://www.cnblogs.com/yilezhu/',\n",
       "   'author': '依乐祝',\n",
       "   'links': [{'rel': 'alternate',\n",
       "     'href': 'http://www.cnblogs.com/yilezhu/p/10767910.html',\n",
       "     'type': 'text/html'},\n",
       "    {'rel': 'alternate',\n",
       "     'type': 'text/html',\n",
       "     'href': 'http://www.cnblogs.com/yilezhu/p/10767910.html'}],\n",
       "   'content': [{'type': 'text/html',\n",
       "     'language': None,\n",
       "     'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "     'value': '【摘要】今天早上六点半左右微信群里就看到张队发的关于.NET Spark大数据的链接https://devblogs.microsoft.com/dotnet/introducing net for apache spark/ ，正印证了“微软在不断通过.NET Core补齐各领域开发，真正实现一种语言的跨 <a href=\"http://www.cnblogs.com/yilezhu/p/10767910.html\" target=\"_blank\">阅读全文</a>'}]},\n",
       "  {'id': 'http://www.cnblogs.com/cjsblog/p/10764105.html',\n",
       "   'guidislink': True,\n",
       "   'link': 'http://www.cnblogs.com/cjsblog/p/10764105.html',\n",
       "   'title': 'Docker 快速开始 - 不要乱摸',\n",
       "   'title_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': 'Docker 快速开始 - 不要乱摸'},\n",
       "   'summary': '1. 概念 对于开发人员和系统管理员来说，Docker是一个使用容器开发、部署和运行应用程序的平台。使用Linux容器部署应用程序称为容器化。容器并不新鲜，但是将它们用于轻松部署应用程序却很新鲜。 容器化越来越受欢迎，是因为容器有以下特点： 灵活性：即使是最复杂的应用程序也可以被容器化 轻量级：容器',\n",
       "   'summary_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': '1. 概念 对于开发人员和系统管理员来说，Docker是一个使用容器开发、部署和运行应用程序的平台。使用Linux容器部署应用程序称为容器化。容器并不新鲜，但是将它们用于轻松部署应用程序却很新鲜。 容器化越来越受欢迎，是因为容器有以下特点： 灵活性：即使是最复杂的应用程序也可以被容器化 轻量级：容器'},\n",
       "   'published': '2019-04-25T05:30:00Z',\n",
       "   'published_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=5, tm_min=30, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'updated': '2019-04-25T05:30:00Z',\n",
       "   'updated_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=5, tm_min=30, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'authors': [{'name': '不要乱摸', 'href': 'http://www.cnblogs.com/cjsblog/'}],\n",
       "   'author_detail': {'name': '不要乱摸',\n",
       "    'href': 'http://www.cnblogs.com/cjsblog/'},\n",
       "   'href': 'http://www.cnblogs.com/cjsblog/',\n",
       "   'author': '不要乱摸',\n",
       "   'links': [{'rel': 'alternate',\n",
       "     'href': 'http://www.cnblogs.com/cjsblog/p/10764105.html',\n",
       "     'type': 'text/html'},\n",
       "    {'rel': 'alternate',\n",
       "     'type': 'text/html',\n",
       "     'href': 'http://www.cnblogs.com/cjsblog/p/10764105.html'}],\n",
       "   'content': [{'type': 'text/html',\n",
       "     'language': None,\n",
       "     'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "     'value': '【摘要】1. 概念 对于开发人员和系统管理员来说，Docker是一个使用容器开发、部署和运行应用程序的平台。使用Linux容器部署应用程序称为容器化。容器并不新鲜，但是将它们用于轻松部署应用程序却很新鲜。 容器化越来越受欢迎，是因为容器有以下特点： 灵活性：即使是最复杂的应用程序也可以被容器化 轻量级：容器 <a href=\"http://www.cnblogs.com/cjsblog/p/10764105.html\" target=\"_blank\">阅读全文</a>'}]},\n",
       "  {'id': 'http://www.cnblogs.com/quanxiaoha/p/10767776.html',\n",
       "   'guidislink': True,\n",
       "   'link': 'http://www.cnblogs.com/quanxiaoha/p/10767776.html',\n",
       "   'title': '这可能是史上最好的 Java8 新特性 Stream 流教程 - 犬小哈',\n",
       "   'title_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': '这可能是史上最好的 Java8 新特性 Stream 流教程 - 犬小哈'},\n",
       "   'summary': '本文翻译自 \"https://winterbe.com/posts/2014/07/31/java8 stream tutorial examples/\" 作者: @Winterbe 欢迎关注个人微信公众号: 小哈学Java 个人网站: \"https://www.exception.site/jav',\n",
       "   'summary_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': '本文翻译自 \"https://winterbe.com/posts/2014/07/31/java8 stream tutorial examples/\" 作者: @Winterbe 欢迎关注个人微信公众号: 小哈学Java 个人网站: \"https://www.exception.site/jav'},\n",
       "   'published': '2019-04-25T04:53:00Z',\n",
       "   'published_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=4, tm_min=53, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'updated': '2019-04-25T04:53:00Z',\n",
       "   'updated_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=4, tm_min=53, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'authors': [{'name': '犬小哈', 'href': 'http://www.cnblogs.com/quanxiaoha/'}],\n",
       "   'author_detail': {'name': '犬小哈',\n",
       "    'href': 'http://www.cnblogs.com/quanxiaoha/'},\n",
       "   'href': 'http://www.cnblogs.com/quanxiaoha/',\n",
       "   'author': '犬小哈',\n",
       "   'links': [{'rel': 'alternate',\n",
       "     'href': 'http://www.cnblogs.com/quanxiaoha/p/10767776.html',\n",
       "     'type': 'text/html'},\n",
       "    {'rel': 'alternate',\n",
       "     'type': 'text/html',\n",
       "     'href': 'http://www.cnblogs.com/quanxiaoha/p/10767776.html'}],\n",
       "   'content': [{'type': 'text/html',\n",
       "     'language': None,\n",
       "     'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "     'value': '【摘要】本文翻译自 \"https://winterbe.com/posts/2014/07/31/java8 stream tutorial examples/\" 作者: @Winterbe 欢迎关注个人微信公众号: 小哈学Java 个人网站: \"https://www.exception.site/jav <a href=\"http://www.cnblogs.com/quanxiaoha/p/10767776.html\" target=\"_blank\">阅读全文</a>'}]},\n",
       "  {'id': 'http://www.cnblogs.com/zyskr/p/10765032.html',\n",
       "   'guidislink': True,\n",
       "   'link': 'http://www.cnblogs.com/zyskr/p/10765032.html',\n",
       "   'title': 'JS原型--原型链 - 停车坐爱枫林晚',\n",
       "   'title_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': 'JS原型--原型链 - 停车坐爱枫林晚'},\n",
       "   'summary': '构造函数-->原型 >prototype-->__proto__-->constructor-->原型链 构造函数 什么是构造函数？我理解构造函数就是可以用来生成实例的函数。 上面的代码，f是函数Func new出来的实例，f是函数Func的实例，所以Func被称为构造函数。那么 Func的构造函数',\n",
       "   'summary_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': '构造函数-->原型 >prototype-->__proto__-->constructor-->原型链 构造函数 什么是构造函数？我理解构造函数就是可以用来生成实例的函数。 上面的代码，f是函数Func new出来的实例，f是函数Func的实例，所以Func被称为构造函数。那么 Func的构造函数'},\n",
       "   'published': '2019-04-25T04:28:00Z',\n",
       "   'published_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=4, tm_min=28, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'updated': '2019-04-25T04:28:00Z',\n",
       "   'updated_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=4, tm_min=28, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'authors': [{'name': '停车坐爱枫林晚', 'href': 'http://www.cnblogs.com/zyskr/'}],\n",
       "   'author_detail': {'name': '停车坐爱枫林晚',\n",
       "    'href': 'http://www.cnblogs.com/zyskr/'},\n",
       "   'href': 'http://www.cnblogs.com/zyskr/',\n",
       "   'author': '停车坐爱枫林晚',\n",
       "   'links': [{'rel': 'alternate',\n",
       "     'href': 'http://www.cnblogs.com/zyskr/p/10765032.html',\n",
       "     'type': 'text/html'},\n",
       "    {'rel': 'alternate',\n",
       "     'type': 'text/html',\n",
       "     'href': 'http://www.cnblogs.com/zyskr/p/10765032.html'}],\n",
       "   'content': [{'type': 'text/html',\n",
       "     'language': None,\n",
       "     'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "     'value': '【摘要】构造函数-->原型 >prototype-->__proto__-->constructor-->原型链 构造函数 什么是构造函数？我理解构造函数就是可以用来生成实例的函数。 上面的代码，f是函数Func new出来的实例，f是函数Func的实例，所以Func被称为构造函数。那么 Func的构造函数 <a href=\"http://www.cnblogs.com/zyskr/p/10765032.html\" target=\"_blank\">阅读全文</a>'}]},\n",
       "  {'id': 'http://www.cnblogs.com/rolandlee/p/10767600.html',\n",
       "   'guidislink': True,\n",
       "   'link': 'http://www.cnblogs.com/rolandlee/p/10767600.html',\n",
       "   'title': '网站跨域的五种解决方式 - 不会敲代码的老王',\n",
       "   'title_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': '网站跨域的五种解决方式 - 不会敲代码的老王'},\n",
       "   'summary': '1、什么是跨越？ 一个网页向另一个不同域名/不同协议/不同端口的网页请求资源，这就是跨域。 跨域原因产生：在当前域名请求网站中，默认不允许通过ajax请求发送其他域名。 2、为什么会产生跨域请求？ 因为浏览器使用了同源策略 3、什么是同源策略？ 同源策略是Netscape提出的一个著名的安全策略，现',\n",
       "   'summary_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': '1、什么是跨越？ 一个网页向另一个不同域名/不同协议/不同端口的网页请求资源，这就是跨域。 跨域原因产生：在当前域名请求网站中，默认不允许通过ajax请求发送其他域名。 2、为什么会产生跨域请求？ 因为浏览器使用了同源策略 3、什么是同源策略？ 同源策略是Netscape提出的一个著名的安全策略，现'},\n",
       "   'published': '2019-04-25T04:00:00Z',\n",
       "   'published_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=4, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'updated': '2019-04-25T04:00:00Z',\n",
       "   'updated_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=4, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'authors': [{'name': '不会敲代码的老王',\n",
       "     'href': 'http://www.cnblogs.com/rolandlee/'}],\n",
       "   'author_detail': {'name': '不会敲代码的老王',\n",
       "    'href': 'http://www.cnblogs.com/rolandlee/'},\n",
       "   'href': 'http://www.cnblogs.com/rolandlee/',\n",
       "   'author': '不会敲代码的老王',\n",
       "   'links': [{'rel': 'alternate',\n",
       "     'href': 'http://www.cnblogs.com/rolandlee/p/10767600.html',\n",
       "     'type': 'text/html'},\n",
       "    {'rel': 'alternate',\n",
       "     'type': 'text/html',\n",
       "     'href': 'http://www.cnblogs.com/rolandlee/p/10767600.html'}],\n",
       "   'content': [{'type': 'text/html',\n",
       "     'language': None,\n",
       "     'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "     'value': '【摘要】1、什么是跨越？ 一个网页向另一个不同域名/不同协议/不同端口的网页请求资源，这就是跨域。 跨域原因产生：在当前域名请求网站中，默认不允许通过ajax请求发送其他域名。 2、为什么会产生跨域请求？ 因为浏览器使用了同源策略 3、什么是同源策略？ 同源策略是Netscape提出的一个著名的安全策略，现 <a href=\"http://www.cnblogs.com/rolandlee/p/10767600.html\" target=\"_blank\">阅读全文</a>'}]},\n",
       "  {'id': 'http://www.cnblogs.com/Alandre/p/10767558.html',\n",
       "   'guidislink': True,\n",
       "   'link': 'http://www.cnblogs.com/Alandre/p/10767558.html',\n",
       "   'title': 'ES 集群上，业务单点如何优化升级？ - www.bysocket.com',\n",
       "   'title_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': 'ES 集群上，业务单点如何优化升级？ - www.bysocket.com'},\n",
       "   'summary': '摘要: 原创出处 https://www.bysocket.com 「公众号：泥瓦匠BYSocket 」欢迎关注和转载，保留摘要，谢谢！ ES 基础 ES 集群 ES 集群上业务优化 一、ES 基础 ES 的安装下载，网上一大片，我这边不在重复。可以看看我以前做的小笔记： Spring Boot 2',\n",
       "   'summary_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': '摘要: 原创出处 https://www.bysocket.com 「公众号：泥瓦匠BYSocket 」欢迎关注和转载，保留摘要，谢谢！ ES 基础 ES 集群 ES 集群上业务优化 一、ES 基础 ES 的安装下载，网上一大片，我这边不在重复。可以看看我以前做的小笔记： Spring Boot 2'},\n",
       "   'published': '2019-04-25T03:53:00Z',\n",
       "   'published_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=3, tm_min=53, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'updated': '2019-04-25T03:53:00Z',\n",
       "   'updated_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=3, tm_min=53, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'authors': [{'name': 'www.bysocket.com',\n",
       "     'href': 'http://www.cnblogs.com/Alandre/'}],\n",
       "   'author_detail': {'name': 'www.bysocket.com',\n",
       "    'href': 'http://www.cnblogs.com/Alandre/'},\n",
       "   'href': 'http://www.cnblogs.com/Alandre/',\n",
       "   'author': 'www.bysocket.com',\n",
       "   'links': [{'rel': 'alternate',\n",
       "     'href': 'http://www.cnblogs.com/Alandre/p/10767558.html',\n",
       "     'type': 'text/html'},\n",
       "    {'rel': 'alternate',\n",
       "     'type': 'text/html',\n",
       "     'href': 'http://www.cnblogs.com/Alandre/p/10767558.html'}],\n",
       "   'content': [{'type': 'text/html',\n",
       "     'language': None,\n",
       "     'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "     'value': '【摘要】摘要: 原创出处 https://www.bysocket.com 「公众号：泥瓦匠BYSocket 」欢迎关注和转载，保留摘要，谢谢！ ES 基础 ES 集群 ES 集群上业务优化 一、ES 基础 ES 的安装下载，网上一大片，我这边不在重复。可以看看我以前做的小笔记： Spring Boot 2 <a href=\"http://www.cnblogs.com/Alandre/p/10767558.html\" target=\"_blank\">阅读全文</a>'}]},\n",
       "  {'id': 'http://www.cnblogs.com/upyun/p/10767548.html',\n",
       "   'guidislink': True,\n",
       "   'link': 'http://www.cnblogs.com/upyun/p/10767548.html',\n",
       "   'title': 'HSTS 详解，让 HTTPS 更安全 - 又拍云',\n",
       "   'title_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': 'HSTS 详解，让 HTTPS 更安全 - 又拍云'},\n",
       "   'summary': '随着互联网的快速发展，人们在生活中越来越离不开互联网。无论是社交、购物还是搜索，互联网都能给人带来很多的便捷。与此同时，由于用户对网络安全的不了解和一些网站、协议的安全漏洞，让很多用户的个人信息数据“裸露”在互联网中。为此谷歌在 Chrome 68 版本后，其界面将会让使用者更容易了解 HTTP 网',\n",
       "   'summary_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': '随着互联网的快速发展，人们在生活中越来越离不开互联网。无论是社交、购物还是搜索，互联网都能给人带来很多的便捷。与此同时，由于用户对网络安全的不了解和一些网站、协议的安全漏洞，让很多用户的个人信息数据“裸露”在互联网中。为此谷歌在 Chrome 68 版本后，其界面将会让使用者更容易了解 HTTP 网'},\n",
       "   'published': '2019-04-25T03:52:00Z',\n",
       "   'published_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=3, tm_min=52, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'updated': '2019-04-25T03:52:00Z',\n",
       "   'updated_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=3, tm_min=52, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'authors': [{'name': '又拍云', 'href': 'http://www.cnblogs.com/upyun/'}],\n",
       "   'author_detail': {'name': '又拍云', 'href': 'http://www.cnblogs.com/upyun/'},\n",
       "   'href': 'http://www.cnblogs.com/upyun/',\n",
       "   'author': '又拍云',\n",
       "   'links': [{'rel': 'alternate',\n",
       "     'href': 'http://www.cnblogs.com/upyun/p/10767548.html',\n",
       "     'type': 'text/html'},\n",
       "    {'rel': 'alternate',\n",
       "     'type': 'text/html',\n",
       "     'href': 'http://www.cnblogs.com/upyun/p/10767548.html'}],\n",
       "   'content': [{'type': 'text/html',\n",
       "     'language': None,\n",
       "     'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "     'value': '【摘要】随着互联网的快速发展，人们在生活中越来越离不开互联网。无论是社交、购物还是搜索，互联网都能给人带来很多的便捷。与此同时，由于用户对网络安全的不了解和一些网站、协议的安全漏洞，让很多用户的个人信息数据“裸露”在互联网中。为此谷歌在 Chrome 68 版本后，其界面将会让使用者更容易了解 HTTP 网 <a href=\"http://www.cnblogs.com/upyun/p/10767548.html\" target=\"_blank\">阅读全文</a>'}]},\n",
       "  {'id': 'http://www.cnblogs.com/rock-roll/p/10763383.html',\n",
       "   'guidislink': True,\n",
       "   'link': 'http://www.cnblogs.com/rock-roll/p/10763383.html',\n",
       "   'title': 'Redux的中间件原理分析 - james·von',\n",
       "   'title_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': 'Redux的中间件原理分析 - james·von'},\n",
       "   'summary': 'redux的中间件对于使用过redux的各位都不会感到陌生，通过应用上我们需要的所有要应用在redux流程上的中间件，我们可以加强dispatch的功能。最近也有一些初学者同时和实习生在询问中间件有关的东西，笔者就把之前分析的东西放在这里分享分享，内有不对之处，还烦请指明。本文只对中间件涉及到的cr',\n",
       "   'summary_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': 'redux的中间件对于使用过redux的各位都不会感到陌生，通过应用上我们需要的所有要应用在redux流程上的中间件，我们可以加强dispatch的功能。最近也有一些初学者同时和实习生在询问中间件有关的东西，笔者就把之前分析的东西放在这里分享分享，内有不对之处，还烦请指明。本文只对中间件涉及到的cr'},\n",
       "   'published': '2019-04-25T03:42:00Z',\n",
       "   'published_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=3, tm_min=42, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'updated': '2019-04-25T03:42:00Z',\n",
       "   'updated_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=3, tm_min=42, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'authors': [{'name': 'james&#183;von',\n",
       "     'href': 'http://www.cnblogs.com/rock-roll/'}],\n",
       "   'author_detail': {'name': 'james&#183;von',\n",
       "    'href': 'http://www.cnblogs.com/rock-roll/'},\n",
       "   'href': 'http://www.cnblogs.com/rock-roll/',\n",
       "   'author': 'james&#183;von',\n",
       "   'links': [{'rel': 'alternate',\n",
       "     'href': 'http://www.cnblogs.com/rock-roll/p/10763383.html',\n",
       "     'type': 'text/html'},\n",
       "    {'rel': 'alternate',\n",
       "     'type': 'text/html',\n",
       "     'href': 'http://www.cnblogs.com/rock-roll/p/10763383.html'}],\n",
       "   'content': [{'type': 'text/html',\n",
       "     'language': None,\n",
       "     'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "     'value': '【摘要】redux的中间件对于使用过redux的各位都不会感到陌生，通过应用上我们需要的所有要应用在redux流程上的中间件，我们可以加强dispatch的功能。最近也有一些初学者同时和实习生在询问中间件有关的东西，笔者就把之前分析的东西放在这里分享分享，内有不对之处，还烦请指明。本文只对中间件涉及到的cr <a href=\"http://www.cnblogs.com/rock-roll/p/10763383.html\" target=\"_blank\">阅读全文</a>'}]},\n",
       "  {'id': 'http://www.cnblogs.com/brooksj/p/10767443.html',\n",
       "   'guidislink': True,\n",
       "   'link': 'http://www.cnblogs.com/brooksj/p/10767443.html',\n",
       "   'title': 'LDA && NCA: 降维与度量学习 - 编程匠心者',\n",
       "   'title_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': 'LDA && NCA: 降维与度量学习 - 编程匠心者'},\n",
       "   'summary': '已迁移到我新博客,阅读体验更佳 \"LDA && NCA: 降维与度量学习\" 代码实现放在我的github上: \"click me\" 一、Linear Discriminant Analysis(LDA) 1.1 Rationale   &nbs',\n",
       "   'summary_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': '已迁移到我新博客,阅读体验更佳 \"LDA && NCA: 降维与度量学习\" 代码实现放在我的github上: \"click me\" 一、Linear Discriminant Analysis(LDA) 1.1 Rationale   &nbs'},\n",
       "   'published': '2019-04-25T03:39:00Z',\n",
       "   'published_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=3, tm_min=39, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'updated': '2019-04-25T03:39:00Z',\n",
       "   'updated_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=3, tm_min=39, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'authors': [{'name': '编程匠心者', 'href': 'http://www.cnblogs.com/brooksj/'}],\n",
       "   'author_detail': {'name': '编程匠心者',\n",
       "    'href': 'http://www.cnblogs.com/brooksj/'},\n",
       "   'href': 'http://www.cnblogs.com/brooksj/',\n",
       "   'author': '编程匠心者',\n",
       "   'links': [{'rel': 'alternate',\n",
       "     'href': 'http://www.cnblogs.com/brooksj/p/10767443.html',\n",
       "     'type': 'text/html'},\n",
       "    {'rel': 'alternate',\n",
       "     'type': 'text/html',\n",
       "     'href': 'http://www.cnblogs.com/brooksj/p/10767443.html'}],\n",
       "   'content': [{'type': 'text/html',\n",
       "     'language': None,\n",
       "     'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "     'value': '【摘要】已迁移到我新博客,阅读体验更佳 \"LDA && NCA: 降维与度量学习\" 代码实现放在我的github上: \"click me\" 一、Linear Discriminant Analysis(LDA) 1.1 Rationale   &nbs <a href=\"http://www.cnblogs.com/brooksj/p/10767443.html\" target=\"_blank\">阅读全文</a>'}]},\n",
       "  {'id': 'http://www.cnblogs.com/Halburt/p/10767389.html',\n",
       "   'guidislink': True,\n",
       "   'link': 'http://www.cnblogs.com/Halburt/p/10767389.html',\n",
       "   'title': '带你找到五一最省的旅游路线【dijkstra算法推导详解】 - Halburt',\n",
       "   'title_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': '带你找到五一最省的旅游路线【dijkstra算法推导详解】 - Halburt'},\n",
       "   'summary': '前言 五一快到了，小张准备去旅游了！ 查了查到各地的机票 因为今年被扣工资扣得很惨，小张手头不是很宽裕，必须精打细算。他想弄清去各个城市的最低开销。 【嗯，不用考虑回来的开销。小张准备找警察叔叔说自己被拐卖，免费被送回来。】 如果他想从珠海飞到拉萨，最少要花多少机票钱呢？下面就说到我们今天要说的这个',\n",
       "   'summary_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': '前言 五一快到了，小张准备去旅游了！ 查了查到各地的机票 因为今年被扣工资扣得很惨，小张手头不是很宽裕，必须精打细算。他想弄清去各个城市的最低开销。 【嗯，不用考虑回来的开销。小张准备找警察叔叔说自己被拐卖，免费被送回来。】 如果他想从珠海飞到拉萨，最少要花多少机票钱呢？下面就说到我们今天要说的这个'},\n",
       "   'published': '2019-04-25T03:33:00Z',\n",
       "   'published_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=3, tm_min=33, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'updated': '2019-04-25T03:33:00Z',\n",
       "   'updated_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=3, tm_min=33, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'authors': [{'name': 'Halburt', 'href': 'http://www.cnblogs.com/Halburt/'}],\n",
       "   'author_detail': {'name': 'Halburt',\n",
       "    'href': 'http://www.cnblogs.com/Halburt/'},\n",
       "   'href': 'http://www.cnblogs.com/Halburt/',\n",
       "   'author': 'Halburt',\n",
       "   'links': [{'rel': 'alternate',\n",
       "     'href': 'http://www.cnblogs.com/Halburt/p/10767389.html',\n",
       "     'type': 'text/html'},\n",
       "    {'rel': 'alternate',\n",
       "     'type': 'text/html',\n",
       "     'href': 'http://www.cnblogs.com/Halburt/p/10767389.html'}],\n",
       "   'content': [{'type': 'text/html',\n",
       "     'language': None,\n",
       "     'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "     'value': '【摘要】前言 五一快到了，小张准备去旅游了！ 查了查到各地的机票 因为今年被扣工资扣得很惨，小张手头不是很宽裕，必须精打细算。他想弄清去各个城市的最低开销。 【嗯，不用考虑回来的开销。小张准备找警察叔叔说自己被拐卖，免费被送回来。】 如果他想从珠海飞到拉萨，最少要花多少机票钱呢？下面就说到我们今天要说的这个 <a href=\"http://www.cnblogs.com/Halburt/p/10767389.html\" target=\"_blank\">阅读全文</a>'}]},\n",
       "  {'id': 'http://www.cnblogs.com/worktile/p/10767287.html',\n",
       "   'guidislink': True,\n",
       "   'link': 'http://www.cnblogs.com/worktile/p/10767287.html',\n",
       "   'title': '通过改进团队流程最大限度发挥Scrum的优势 - Worktile',\n",
       "   'title_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': '通过改进团队流程最大限度发挥Scrum的优势 - Worktile'},\n",
       "   'summary': '团队如何最大限度地发挥Scrum和敏捷的优势？ 回想一下，Scrum团队在Scrum的框架内定义了自己的流程。这其中包括方法、工具和互动以及如何履行Scrum角色的职责、如何使用工件和事件等。 如何确定团队做什么以及怎么做？从产品管理方法到研发及质量管理方法。从团队的沟通协作方式到团队成员如何有效利',\n",
       "   'summary_detail': {'type': 'text/plain',\n",
       "    'language': None,\n",
       "    'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "    'value': '团队如何最大限度地发挥Scrum和敏捷的优势？ 回想一下，Scrum团队在Scrum的框架内定义了自己的流程。这其中包括方法、工具和互动以及如何履行Scrum角色的职责、如何使用工件和事件等。 如何确定团队做什么以及怎么做？从产品管理方法到研发及质量管理方法。从团队的沟通协作方式到团队成员如何有效利'},\n",
       "   'published': '2019-04-25T03:23:00Z',\n",
       "   'published_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=3, tm_min=23, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'updated': '2019-04-25T03:23:00Z',\n",
       "   'updated_parsed': time.struct_time(tm_year=2019, tm_mon=4, tm_mday=25, tm_hour=3, tm_min=23, tm_sec=0, tm_wday=3, tm_yday=115, tm_isdst=0),\n",
       "   'authors': [{'name': 'Worktile',\n",
       "     'href': 'http://www.cnblogs.com/worktile/'}],\n",
       "   'author_detail': {'name': 'Worktile',\n",
       "    'href': 'http://www.cnblogs.com/worktile/'},\n",
       "   'href': 'http://www.cnblogs.com/worktile/',\n",
       "   'author': 'Worktile',\n",
       "   'links': [{'rel': 'alternate',\n",
       "     'href': 'http://www.cnblogs.com/worktile/p/10767287.html',\n",
       "     'type': 'text/html'},\n",
       "    {'rel': 'alternate',\n",
       "     'type': 'text/html',\n",
       "     'href': 'http://www.cnblogs.com/worktile/p/10767287.html'}],\n",
       "   'content': [{'type': 'text/html',\n",
       "     'language': None,\n",
       "     'base': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       "     'value': '【摘要】团队如何最大限度地发挥Scrum和敏捷的优势？ 回想一下，Scrum团队在Scrum的框架内定义了自己的流程。这其中包括方法、工具和互动以及如何履行Scrum角色的职责、如何使用工件和事件等。 如何确定团队做什么以及怎么做？从产品管理方法到研发及质量管理方法。从团队的沟通协作方式到团队成员如何有效利 <a href=\"http://www.cnblogs.com/worktile/p/10767287.html\" target=\"_blank\">阅读全文</a>'}]}],\n",
       " 'bozo': 0,\n",
       " 'headers': {'Content-Length': '30225',\n",
       "  'Cache-Control': 'private',\n",
       "  'Content-Type': 'application/xml',\n",
       "  'Date': 'Thu, 25 Apr 2019 07:10:18 GMT',\n",
       "  'Keep-Alive': 'timeout=58',\n",
       "  'Server': 'Microsoft-IIS/10.0',\n",
       "  'Set-Cookie': 'ASP.NET_SessionId=pjcwembc1bwaahqybrd34uyi; path=/; HttpOnly',\n",
       "  'X-Aspnet-Version': '4.0.30319',\n",
       "  'X-Aspnetmvc-Version': '4.0',\n",
       "  'X-Powered-By': 'ASP.NET'},\n",
       " 'href': 'http://feed.cnblogs.com/blog/sitehome/rss',\n",
       " 'status': 200,\n",
       " 'encoding': 'utf-8',\n",
       " 'version': 'atom10',\n",
       " 'namespaces': {'': 'http://www.w3.org/2005/Atom'}}"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import feedparser\n",
    "llog = feedparser.parse(\"http://feed.cnblogs.com/blog/sitehome/rss\")\n",
    "llog"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'博客园_首页'"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "llog[\"feed\"][\"title\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "20"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(llog.entries)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'KnockOut 绑定之foreach绑定 - GavinJay'"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "post = llog.entries[2]\n",
    "post.title"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'【摘要】foreach绑定对于数组中的每一个元素复制一节标记语言，也就是html，并且将这节标记语言和数组里面的每一个元素绑定。当我们呈现一'"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "content = post.content[0].value\n",
    "content[:70]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['【摘要】foreach绑定对于数组中的每一个元素复制一节标记语言，也就是html，并且将这节标记语言和数组里面的每一个元素绑定。当我们呈现一组list数据，或者一个表格的时候，十分有用。',\n",
       " '如果你绑定的数组是一个',\n",
       " \"''\",\n",
       " '监控数组',\n",
       " \"''\",\n",
       " ',',\n",
       " 'observable',\n",
       " 'array',\n",
       " ',',\n",
       " '(',\n",
       " '和wpf里面的ObservableCollec',\n",
       " '阅读全文']"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "raw = BeautifulSoup(content).get_text()\n",
    "word_tokenize(raw)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7、读取本地文件"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "' 沁园春·雪\\n作者：毛泽东\\n北国风光，千里冰封，万里雪飘。\\n望长城内外，惟余莽莽；大河上下，顿失滔滔。\\n山舞银蛇，原驰蜡象，欲与天公试比高。\\n须晴日，看红装素裹，分外妖娆。\\n江山如此多娇，引无数英雄竞折腰。\\n惜秦皇汉武，略输文采；唐宗宋祖，稍逊风骚。 '"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "f = open(\"3.document.txt\",'r') # 'r'意味着以只读方式打开文件（默认），'U'表示“通用”，它让我们忽略不同的换行约定。\n",
    "raw = f.read()\n",
    "raw"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['picture',\n",
       " '【Python自然语言处理】读书笔记：第一章：语言处理与Python.md~',\n",
       " 'README.md',\n",
       " '.git',\n",
       " '【Python自然语言处理】读书笔记：第三章：处理原始文本.ipynb',\n",
       " '.ipynb_checkpoints',\n",
       " '【Python自然语言处理】读书笔记：第二章：获得文本语料和词汇资源.md',\n",
       " '3.document.txt',\n",
       " '【Python自然语言处理】读书笔记：第一章：语言处理与Python.md',\n",
       " '【Python自然语言处理】读书笔记：第二章：获得文本语料和词汇资源.md~']"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import os\n",
    "os.listdir(\".\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "沁园春·雪\n",
      "作者：毛泽东\n",
      "北国风光，千里冰封，万里雪飘。\n",
      "望长城内外，惟余莽莽；大河上下，顿失滔滔。\n",
      "山舞银蛇，原驰蜡象，欲与天公试比高。\n",
      "须晴日，看红装素裹，分外妖娆。\n",
      "江山如此多娇，引无数英雄竞折腰。\n",
      "惜秦皇汉武，略输文采；唐宗宋祖，稍逊风骚。\n"
     ]
    }
   ],
   "source": [
    "f = open(\"3.document.txt\",\"r\")\n",
    "for line in f:\n",
    "    print(line.strip()) # strip()方法删除输入行结尾的换行符。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 8、从PDF、MS Word 及其他二进制格式中提取文本"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "文字常常以二进制格式出现，如PDF 和MSWord，只能使用专门的软件打开。第三方函数库如pypdf和pywin32提供了对这些格式的访问。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 9、NLP 的流程"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![3.1.png](./picture/3.1.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 10、str"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "            very\n",
      "          veryvery\n",
      "        veryveryvery\n",
      "      veryveryveryvery\n",
      "    veryveryveryveryvery\n",
      "  veryveryveryveryveryvery\n",
      "veryveryveryveryveryveryvery\n",
      "  veryveryveryveryveryvery\n",
      "    veryveryveryveryvery\n",
      "      veryveryveryvery\n",
      "        veryveryvery\n",
      "          veryvery\n",
      "            very\n"
     ]
    }
   ],
   "source": [
    ">>> a = [1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1]\n",
    ">>> b = [' ' * 2 * (7 - i) + 'very' * i for i in a]\n",
    ">>> for line in b:\n",
    "...     print(line)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on class str in module builtins:\n",
      "\n",
      "class str(object)\n",
      " |  str(object='') -> str\n",
      " |  str(bytes_or_buffer[, encoding[, errors]]) -> str\n",
      " |  \n",
      " |  Create a new string object from the given object. If encoding or\n",
      " |  errors is specified, then the object must expose a data buffer\n",
      " |  that will be decoded using the given encoding and error handler.\n",
      " |  Otherwise, returns the result of object.__str__() (if defined)\n",
      " |  or repr(object).\n",
      " |  encoding defaults to sys.getdefaultencoding().\n",
      " |  errors defaults to 'strict'.\n",
      " |  \n",
      " |  Methods defined here:\n",
      " |  \n",
      " |  __add__(self, value, /)\n",
      " |      Return self+value.\n",
      " |  \n",
      " |  __contains__(self, key, /)\n",
      " |      Return key in self.\n",
      " |  \n",
      " |  __eq__(self, value, /)\n",
      " |      Return self==value.\n",
      " |  \n",
      " |  __format__(...)\n",
      " |      S.__format__(format_spec) -> str\n",
      " |      \n",
      " |      Return a formatted version of S as described by format_spec.\n",
      " |  \n",
      " |  __ge__(self, value, /)\n",
      " |      Return self>=value.\n",
      " |  \n",
      " |  __getattribute__(self, name, /)\n",
      " |      Return getattr(self, name).\n",
      " |  \n",
      " |  __getitem__(self, key, /)\n",
      " |      Return self[key].\n",
      " |  \n",
      " |  __getnewargs__(...)\n",
      " |  \n",
      " |  __gt__(self, value, /)\n",
      " |      Return self>value.\n",
      " |  \n",
      " |  __hash__(self, /)\n",
      " |      Return hash(self).\n",
      " |  \n",
      " |  __iter__(self, /)\n",
      " |      Implement iter(self).\n",
      " |  \n",
      " |  __le__(self, value, /)\n",
      " |      Return self<=value.\n",
      " |  \n",
      " |  __len__(self, /)\n",
      " |      Return len(self).\n",
      " |  \n",
      " |  __lt__(self, value, /)\n",
      " |      Return self<value.\n",
      " |  \n",
      " |  __mod__(self, value, /)\n",
      " |      Return self%value.\n",
      " |  \n",
      " |  __mul__(self, value, /)\n",
      " |      Return self*value.n\n",
      " |  \n",
      " |  __ne__(self, value, /)\n",
      " |      Return self!=value.\n",
      " |  \n",
      " |  __new__(*args, **kwargs) from builtins.type\n",
      " |      Create and return a new object.  See help(type) for accurate signature.\n",
      " |  \n",
      " |  __repr__(self, /)\n",
      " |      Return repr(self).\n",
      " |  \n",
      " |  __rmod__(self, value, /)\n",
      " |      Return value%self.\n",
      " |  \n",
      " |  __rmul__(self, value, /)\n",
      " |      Return self*value.\n",
      " |  \n",
      " |  __sizeof__(...)\n",
      " |      S.__sizeof__() -> size of S in memory, in bytes\n",
      " |  \n",
      " |  __str__(self, /)\n",
      " |      Return str(self).\n",
      " |  \n",
      " |  capitalize(...)\n",
      " |      S.capitalize() -> str\n",
      " |      \n",
      " |      Return a capitalized version of S, i.e. make the first character\n",
      " |      have upper case and the rest lower case.\n",
      " |  \n",
      " |  casefold(...)\n",
      " |      S.casefold() -> str\n",
      " |      \n",
      " |      Return a version of S suitable for caseless comparisons.\n",
      " |  \n",
      " |  center(...)\n",
      " |      S.center(width[, fillchar]) -> str\n",
      " |      \n",
      " |      Return S centered in a string of length width. Padding is\n",
      " |      done using the specified fill character (default is a space)\n",
      " |  \n",
      " |  count(...)\n",
      " |      S.count(sub[, start[, end]]) -> int\n",
      " |      \n",
      " |      Return the number of non-overlapping occurrences of substring sub in\n",
      " |      string S[start:end].  Optional arguments start and end are\n",
      " |      interpreted as in slice notation.\n",
      " |  \n",
      " |  encode(...)\n",
      " |      S.encode(encoding='utf-8', errors='strict') -> bytes\n",
      " |      \n",
      " |      Encode S using the codec registered for encoding. Default encoding\n",
      " |      is 'utf-8'. errors may be given to set a different error\n",
      " |      handling scheme. Default is 'strict' meaning that encoding errors raise\n",
      " |      a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and\n",
      " |      'xmlcharrefreplace' as well as any other name registered with\n",
      " |      codecs.register_error that can handle UnicodeEncodeErrors.\n",
      " |  \n",
      " |  endswith(...)\n",
      " |      S.endswith(suffix[, start[, end]]) -> bool\n",
      " |      \n",
      " |      Return True if S ends with the specified suffix, False otherwise.\n",
      " |      With optional start, test S beginning at that position.\n",
      " |      With optional end, stop comparing S at that position.\n",
      " |      suffix can also be a tuple of strings to try.\n",
      " |  \n",
      " |  expandtabs(...)\n",
      " |      S.expandtabs(tabsize=8) -> str\n",
      " |      \n",
      " |      Return a copy of S where all tab characters are expanded using spaces.\n",
      " |      If tabsize is not given, a tab size of 8 characters is assumed.\n",
      " |  \n",
      " |  find(...)\n",
      " |      S.find(sub[, start[, end]]) -> int\n",
      " |      \n",
      " |      Return the lowest index in S where substring sub is found,\n",
      " |      such that sub is contained within S[start:end].  Optional\n",
      " |      arguments start and end are interpreted as in slice notation.\n",
      " |      \n",
      " |      Return -1 on failure.\n",
      " |  \n",
      " |  format(...)\n",
      " |      S.format(*args, **kwargs) -> str\n",
      " |      \n",
      " |      Return a formatted version of S, using substitutions from args and kwargs.\n",
      " |      The substitutions are identified by braces ('{' and '}').\n",
      " |  \n",
      " |  format_map(...)\n",
      " |      S.format_map(mapping) -> str\n",
      " |      \n",
      " |      Return a formatted version of S, using substitutions from mapping.\n",
      " |      The substitutions are identified by braces ('{' and '}').\n",
      " |  \n",
      " |  index(...)\n",
      " |      S.index(sub[, start[, end]]) -> int\n",
      " |      \n",
      " |      Return the lowest index in S where substring sub is found, \n",
      " |      such that sub is contained within S[start:end].  Optional\n",
      " |      arguments start and end are interpreted as in slice notation.\n",
      " |      \n",
      " |      Raises ValueError when the substring is not found.\n",
      " |  \n",
      " |  isalnum(...)\n",
      " |      S.isalnum() -> bool\n",
      " |      \n",
      " |      Return True if all characters in S are alphanumeric\n",
      " |      and there is at least one character in S, False otherwise.\n",
      " |  \n",
      " |  isalpha(...)\n",
      " |      S.isalpha() -> bool\n",
      " |      \n",
      " |      Return True if all characters in S are alphabetic\n",
      " |      and there is at least one character in S, False otherwise.\n",
      " |  \n",
      " |  isdecimal(...)\n",
      " |      S.isdecimal() -> bool\n",
      " |      \n",
      " |      Return True if there are only decimal characters in S,\n",
      " |      False otherwise.\n",
      " |  \n",
      " |  isdigit(...)\n",
      " |      S.isdigit() -> bool\n",
      " |      \n",
      " |      Return True if all characters in S are digits\n",
      " |      and there is at least one character in S, False otherwise.\n",
      " |  \n",
      " |  isidentifier(...)\n",
      " |      S.isidentifier() -> bool\n",
      " |      \n",
      " |      Return True if S is a valid identifier according\n",
      " |      to the language definition.\n",
      " |      \n",
      " |      Use keyword.iskeyword() to test for reserved identifiers\n",
      " |      such as \"def\" and \"class\".\n",
      " |  \n",
      " |  islower(...)\n",
      " |      S.islower() -> bool\n",
      " |      \n",
      " |      Return True if all cased characters in S are lowercase and there is\n",
      " |      at least one cased character in S, False otherwise.\n",
      " |  \n",
      " |  isnumeric(...)\n",
      " |      S.isnumeric() -> bool\n",
      " |      \n",
      " |      Return True if there are only numeric characters in S,\n",
      " |      False otherwise.\n",
      " |  \n",
      " |  isprintable(...)\n",
      " |      S.isprintable() -> bool\n",
      " |      \n",
      " |      Return True if all characters in S are considered\n",
      " |      printable in repr() or S is empty, False otherwise.\n",
      " |  \n",
      " |  isspace(...)\n",
      " |      S.isspace() -> bool\n",
      " |      \n",
      " |      Return True if all characters in S are whitespace\n",
      " |      and there is at least one character in S, False otherwise.\n",
      " |  \n",
      " |  istitle(...)\n",
      " |      S.istitle() -> bool\n",
      " |      \n",
      " |      Return True if S is a titlecased string and there is at least one\n",
      " |      character in S, i.e. upper- and titlecase characters may only\n",
      " |      follow uncased characters and lowercase characters only cased ones.\n",
      " |      Return False otherwise.\n",
      " |  \n",
      " |  isupper(...)\n",
      " |      S.isupper() -> bool\n",
      " |      \n",
      " |      Return True if all cased characters in S are uppercase and there is\n",
      " |      at least one cased character in S, False otherwise.\n",
      " |  \n",
      " |  join(...)\n",
      " |      S.join(iterable) -> str\n",
      " |      \n",
      " |      Return a string which is the concatenation of the strings in the\n",
      " |      iterable.  The separator between elements is S.\n",
      " |  \n",
      " |  ljust(...)\n",
      " |      S.ljust(width[, fillchar]) -> str\n",
      " |      \n",
      " |      Return S left-justified in a Unicode string of length width. Padding is\n",
      " |      done using the specified fill character (default is a space).\n",
      " |  \n",
      " |  lower(...)\n",
      " |      S.lower() -> str\n",
      " |      \n",
      " |      Return a copy of the string S converted to lowercase.\n",
      " |  \n",
      " |  lstrip(...)\n",
      " |      S.lstrip([chars]) -> str\n",
      " |      \n",
      " |      Return a copy of the string S with leading whitespace removed.\n",
      " |      If chars is given and not None, remove characters in chars instead.\n",
      " |  \n",
      " |  partition(...)\n",
      " |      S.partition(sep) -> (head, sep, tail)\n",
      " |      \n",
      " |      Search for the separator sep in S, and return the part before it,\n",
      " |      the separator itself, and the part after it.  If the separator is not\n",
      " |      found, return S and two empty strings.\n",
      " |  \n",
      " |  replace(...)\n",
      " |      S.replace(old, new[, count]) -> str\n",
      " |      \n",
      " |      Return a copy of S with all occurrences of substring\n",
      " |      old replaced by new.  If the optional argument count is\n",
      " |      given, only the first count occurrences are replaced.\n",
      " |  \n",
      " |  rfind(...)\n",
      " |      S.rfind(sub[, start[, end]]) -> int\n",
      " |      \n",
      " |      Return the highest index in S where substring sub is found,\n",
      " |      such that sub is contained within S[start:end].  Optional\n",
      " |      arguments start and end are interpreted as in slice notation.\n",
      " |      \n",
      " |      Return -1 on failure.\n",
      " |  \n",
      " |  rindex(...)\n",
      " |      S.rindex(sub[, start[, end]]) -> int\n",
      " |      \n",
      " |      Return the highest index in S where substring sub is found,\n",
      " |      such that sub is contained within S[start:end].  Optional\n",
      " |      arguments start and end are interpreted as in slice notation.\n",
      " |      \n",
      " |      Raises ValueError when the substring is not found.\n",
      " |  \n",
      " |  rjust(...)\n",
      " |      S.rjust(width[, fillchar]) -> str\n",
      " |      \n",
      " |      Return S right-justified in a string of length width. Padding is\n",
      " |      done using the specified fill character (default is a space).\n",
      " |  \n",
      " |  rpartition(...)\n",
      " |      S.rpartition(sep) -> (head, sep, tail)\n",
      " |      \n",
      " |      Search for the separator sep in S, starting at the end of S, and return\n",
      " |      the part before it, the separator itself, and the part after it.  If the\n",
      " |      separator is not found, return two empty strings and S.\n",
      " |  \n",
      " |  rsplit(...)\n",
      " |      S.rsplit(sep=None, maxsplit=-1) -> list of strings\n",
      " |      \n",
      " |      Return a list of the words in S, using sep as the\n",
      " |      delimiter string, starting at the end of the string and\n",
      " |      working to the front.  If maxsplit is given, at most maxsplit\n",
      " |      splits are done. If sep is not specified, any whitespace string\n",
      " |      is a separator.\n",
      " |  \n",
      " |  rstrip(...)\n",
      " |      S.rstrip([chars]) -> str\n",
      " |      \n",
      " |      Return a copy of the string S with trailing whitespace removed.\n",
      " |      If chars is given and not None, remove characters in chars instead.\n",
      " |  \n",
      " |  split(...)\n",
      " |      S.split(sep=None, maxsplit=-1) -> list of strings\n",
      " |      \n",
      " |      Return a list of the words in S, using sep as the\n",
      " |      delimiter string.  If maxsplit is given, at most maxsplit\n",
      " |      splits are done. If sep is not specified or is None, any\n",
      " |      whitespace string is a separator and empty strings are\n",
      " |      removed from the result.\n",
      " |  \n",
      " |  splitlines(...)\n",
      " |      S.splitlines([keepends]) -> list of strings\n",
      " |      \n",
      " |      Return a list of the lines in S, breaking at line boundaries.\n",
      " |      Line breaks are not included in the resulting list unless keepends\n",
      " |      is given and true.\n",
      " |  \n",
      " |  startswith(...)\n",
      " |      S.startswith(prefix[, start[, end]]) -> bool\n",
      " |      \n",
      " |      Return True if S starts with the specified prefix, False otherwise.\n",
      " |      With optional start, test S beginning at that position.\n",
      " |      With optional end, stop comparing S at that position.\n",
      " |      prefix can also be a tuple of strings to try.\n",
      " |  \n",
      " |  strip(...)\n",
      " |      S.strip([chars]) -> str\n",
      " |      \n",
      " |      Return a copy of the string S with leading and trailing\n",
      " |      whitespace removed.\n",
      " |      If chars is given and not None, remove characters in chars instead.\n",
      " |  \n",
      " |  swapcase(...)\n",
      " |      S.swapcase() -> str\n",
      " |      \n",
      " |      Return a copy of S with uppercase characters converted to lowercase\n",
      " |      and vice versa.\n",
      " |  \n",
      " |  title(...)\n",
      " |      S.title() -> str\n",
      " |      \n",
      " |      Return a titlecased version of S, i.e. words start with title case\n",
      " |      characters, all remaining cased characters have lower case.\n",
      " |  \n",
      " |  translate(...)\n",
      " |      S.translate(table) -> str\n",
      " |      \n",
      " |      Return a copy of the string S in which each character has been mapped\n",
      " |      through the given translation table. The table must implement\n",
      " |      lookup/indexing via __getitem__, for instance a dictionary or list,\n",
      " |      mapping Unicode ordinals to Unicode ordinals, strings, or None. If\n",
      " |      this operation raises LookupError, the character is left untouched.\n",
      " |      Characters mapped to None are deleted.\n",
      " |  \n",
      " |  upper(...)\n",
      " |      S.upper() -> str\n",
      " |      \n",
      " |      Return a copy of S converted to uppercase.\n",
      " |  \n",
      " |  zfill(...)\n",
      " |      S.zfill(width) -> str\n",
      " |      \n",
      " |      Pad a numeric string S with zeros on the left, to fill a field\n",
      " |      of the specified width. The string S is never truncated.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Static methods defined here:\n",
      " |  \n",
      " |  maketrans(x, y=None, z=None, /)\n",
      " |      Return a translation table usable for str.translate().\n",
      " |      \n",
      " |      If there is only one argument, it must be a dictionary mapping Unicode\n",
      " |      ordinals (integers) or characters to Unicode ordinals, strings or None.\n",
      " |      Character keys will be then converted to ordinals.\n",
      " |      If there are two arguments, they must be strings of equal length, and\n",
      " |      in the resulting dictionary, each character in x will be mapped to the\n",
      " |      character at the same position in y. If there is a third argument, it\n",
      " |      must be a string, whose characters will be mapped to None in the result.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(str)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**列表**中的元素可以很大也可以很小，只要我们喜欢：例如，它们可能是段落、句子、短语、单词、字符。\n",
    "\n",
    "因此，我们在一段NLP 代码中可能做的第一件事情就是将一个字符串分词放入一个**字符串列表**中。\n",
    "\n",
    "相反，当我们要将结果写入到一个文件或终端，我们通常会将它们格式化为一个**字符串**。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 3.4 使用正则表达式检测词组搭配"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['a',\n",
       " 'aa',\n",
       " 'aal',\n",
       " 'aalii',\n",
       " 'aam',\n",
       " 'aardvark',\n",
       " 'aardwolf',\n",
       " 'aba',\n",
       " 'abac',\n",
       " 'abaca',\n",
       " 'abacate',\n",
       " 'abacay',\n",
       " 'abacinate',\n",
       " 'abacination',\n",
       " 'abaciscus',\n",
       " 'abacist',\n",
       " 'aback',\n",
       " 'abactinal',\n",
       " 'abactinally',\n",
       " 'abaction',\n",
       " 'abactor',\n",
       " 'abaculus',\n",
       " 'abacus',\n",
       " 'abaff',\n",
       " 'abaft',\n",
       " 'abaisance',\n",
       " 'abaiser',\n",
       " 'abaissed',\n",
       " 'abalienate',\n",
       " 'abalienation',\n",
       " 'abalone',\n",
       " 'abampere',\n",
       " 'abandon',\n",
       " 'abandonable',\n",
       " 'abandoned',\n",
       " 'abandonedly',\n",
       " 'abandonee',\n",
       " 'abandoner',\n",
       " 'abandonment',\n",
       " 'abaptiston',\n",
       " 'abarthrosis',\n",
       " 'abarticular',\n",
       " 'abarticulation',\n",
       " 'abas',\n",
       " 'abase',\n",
       " 'abased',\n",
       " 'abasedly',\n",
       " 'abasedness',\n",
       " 'abasement',\n",
       " 'abaser',\n",
       " 'abash',\n",
       " 'abashed',\n",
       " 'abashedly',\n",
       " 'abashedness',\n",
       " 'abashless',\n",
       " 'abashlessly',\n",
       " 'abashment',\n",
       " 'abasia',\n",
       " 'abasic',\n",
       " 'abask',\n",
       " 'abastardize',\n",
       " 'abatable',\n",
       " 'abate',\n",
       " 'abatement',\n",
       " 'abater',\n",
       " 'abatis',\n",
       " 'abatised',\n",
       " 'abaton',\n",
       " 'abator',\n",
       " 'abattoir',\n",
       " 'abature',\n",
       " 'abave',\n",
       " 'abaxial',\n",
       " 'abaxile',\n",
       " 'abaze',\n",
       " 'abb',\n",
       " 'abbacomes',\n",
       " 'abbacy',\n",
       " 'abbas',\n",
       " 'abbasi',\n",
       " 'abbassi',\n",
       " 'abbatial',\n",
       " 'abbatical',\n",
       " 'abbess',\n",
       " 'abbey',\n",
       " 'abbeystede',\n",
       " 'abbot',\n",
       " 'abbotcy',\n",
       " 'abbotnullius',\n",
       " 'abbotship',\n",
       " 'abbreviate',\n",
       " 'abbreviately',\n",
       " 'abbreviation',\n",
       " 'abbreviator',\n",
       " 'abbreviatory',\n",
       " 'abbreviature',\n",
       " 'abcoulomb',\n",
       " 'abdal',\n",
       " 'abdat',\n",
       " 'abdest',\n",
       " 'abdicable',\n",
       " 'abdicant',\n",
       " 'abdicate',\n",
       " 'abdication',\n",
       " 'abdicative',\n",
       " 'abdicator',\n",
       " 'abditive',\n",
       " 'abditory',\n",
       " 'abdomen',\n",
       " 'abdominal',\n",
       " 'abdominalian',\n",
       " 'abdominally',\n",
       " 'abdominoanterior',\n",
       " 'abdominocardiac',\n",
       " 'abdominocentesis',\n",
       " 'abdominocystic',\n",
       " 'abdominogenital',\n",
       " 'abdominohysterectomy',\n",
       " 'abdominohysterotomy',\n",
       " 'abdominoposterior',\n",
       " 'abdominoscope',\n",
       " 'abdominoscopy',\n",
       " 'abdominothoracic',\n",
       " 'abdominous',\n",
       " 'abdominovaginal',\n",
       " 'abdominovesical',\n",
       " 'abduce',\n",
       " 'abducens',\n",
       " 'abducent',\n",
       " 'abduct',\n",
       " 'abduction',\n",
       " 'abductor',\n",
       " 'abeam',\n",
       " 'abear',\n",
       " 'abearance',\n",
       " 'abecedarian',\n",
       " 'abecedarium',\n",
       " 'abecedary',\n",
       " 'abed',\n",
       " 'abeigh',\n",
       " 'abele',\n",
       " 'abelite',\n",
       " 'abelmosk',\n",
       " 'abeltree',\n",
       " 'abenteric',\n",
       " 'abepithymia',\n",
       " 'aberdevine',\n",
       " 'aberrance',\n",
       " 'aberrancy',\n",
       " 'aberrant',\n",
       " 'aberrate',\n",
       " 'aberration',\n",
       " 'aberrational',\n",
       " 'aberrator',\n",
       " 'aberrometer',\n",
       " 'aberroscope',\n",
       " 'aberuncator',\n",
       " 'abet',\n",
       " 'abetment',\n",
       " 'abettal',\n",
       " 'abettor',\n",
       " 'abevacuation',\n",
       " 'abey',\n",
       " 'abeyance',\n",
       " 'abeyancy',\n",
       " 'abeyant',\n",
       " 'abfarad',\n",
       " 'abhenry',\n",
       " 'abhiseka',\n",
       " 'abhominable',\n",
       " 'abhor',\n",
       " 'abhorrence',\n",
       " 'abhorrency',\n",
       " 'abhorrent',\n",
       " 'abhorrently',\n",
       " 'abhorrer',\n",
       " 'abhorrible',\n",
       " 'abhorring',\n",
       " 'abidal',\n",
       " 'abidance',\n",
       " 'abide',\n",
       " 'abider',\n",
       " 'abidi',\n",
       " 'abiding',\n",
       " 'abidingly',\n",
       " 'abidingness',\n",
       " 'abietate',\n",
       " 'abietene',\n",
       " 'abietic',\n",
       " 'abietin',\n",
       " 'abietineous',\n",
       " 'abietinic',\n",
       " 'abigail',\n",
       " 'abigailship',\n",
       " 'abigeat',\n",
       " 'abigeus',\n",
       " 'abilao',\n",
       " 'ability',\n",
       " 'abilla',\n",
       " 'abilo',\n",
       " 'abintestate',\n",
       " 'abiogenesis',\n",
       " 'abiogenesist',\n",
       " 'abiogenetic',\n",
       " 'abiogenetical',\n",
       " 'abiogenetically',\n",
       " 'abiogenist',\n",
       " 'abiogenous',\n",
       " 'abiogeny',\n",
       " 'abiological',\n",
       " 'abiologically',\n",
       " 'abiology',\n",
       " 'abiosis',\n",
       " 'abiotic',\n",
       " 'abiotrophic',\n",
       " 'abiotrophy',\n",
       " 'abir',\n",
       " 'abirritant',\n",
       " 'abirritate',\n",
       " 'abirritation',\n",
       " 'abirritative',\n",
       " 'abiston',\n",
       " 'abiuret',\n",
       " 'abject',\n",
       " 'abjectedness',\n",
       " 'abjection',\n",
       " 'abjective',\n",
       " 'abjectly',\n",
       " 'abjectness',\n",
       " 'abjoint',\n",
       " 'abjudge',\n",
       " 'abjudicate',\n",
       " 'abjudication',\n",
       " 'abjunction',\n",
       " 'abjunctive',\n",
       " 'abjuration',\n",
       " 'abjuratory',\n",
       " 'abjure',\n",
       " 'abjurement',\n",
       " 'abjurer',\n",
       " 'abkar',\n",
       " 'abkari',\n",
       " 'ablach',\n",
       " 'ablactate',\n",
       " 'ablactation',\n",
       " 'ablare',\n",
       " 'ablastemic',\n",
       " 'ablastous',\n",
       " 'ablate',\n",
       " 'ablation',\n",
       " 'ablatitious',\n",
       " 'ablatival',\n",
       " 'ablative',\n",
       " 'ablator',\n",
       " 'ablaut',\n",
       " 'ablaze',\n",
       " 'able',\n",
       " 'ableeze',\n",
       " 'ablegate',\n",
       " 'ableness',\n",
       " 'ablepharia',\n",
       " 'ablepharon',\n",
       " 'ablepharous',\n",
       " 'ablepsia',\n",
       " 'ableptical',\n",
       " 'ableptically',\n",
       " 'abler',\n",
       " 'ablest',\n",
       " 'ablewhackets',\n",
       " 'ablins',\n",
       " 'abloom',\n",
       " 'ablow',\n",
       " 'ablude',\n",
       " 'abluent',\n",
       " 'ablush',\n",
       " 'ablution',\n",
       " 'ablutionary',\n",
       " 'abluvion',\n",
       " 'ably',\n",
       " 'abmho',\n",
       " 'abnegate',\n",
       " 'abnegation',\n",
       " 'abnegative',\n",
       " 'abnegator',\n",
       " 'abnerval',\n",
       " 'abnet',\n",
       " 'abneural',\n",
       " 'abnormal',\n",
       " 'abnormalism',\n",
       " 'abnormalist',\n",
       " 'abnormality',\n",
       " 'abnormalize',\n",
       " 'abnormally',\n",
       " 'abnormalness',\n",
       " 'abnormity',\n",
       " 'abnormous',\n",
       " 'abnumerable',\n",
       " 'aboard',\n",
       " 'abode',\n",
       " 'abodement',\n",
       " 'abody',\n",
       " 'abohm',\n",
       " 'aboil',\n",
       " 'abolish',\n",
       " 'abolisher',\n",
       " 'abolishment',\n",
       " 'abolition',\n",
       " 'abolitionary',\n",
       " 'abolitionism',\n",
       " 'abolitionist',\n",
       " 'abolitionize',\n",
       " 'abolla',\n",
       " 'aboma',\n",
       " 'abomasum',\n",
       " 'abomasus',\n",
       " 'abominable',\n",
       " 'abominableness',\n",
       " 'abominably',\n",
       " 'abominate',\n",
       " 'abomination',\n",
       " 'abominator',\n",
       " 'abomine',\n",
       " 'aboon',\n",
       " 'aborad',\n",
       " 'aboral',\n",
       " 'aborally',\n",
       " 'abord',\n",
       " 'aboriginal',\n",
       " 'aboriginality',\n",
       " 'aboriginally',\n",
       " 'aboriginary',\n",
       " 'aborigine',\n",
       " 'abort',\n",
       " 'aborted',\n",
       " 'aborticide',\n",
       " 'abortient',\n",
       " 'abortifacient',\n",
       " 'abortin',\n",
       " 'abortion',\n",
       " 'abortional',\n",
       " 'abortionist',\n",
       " 'abortive',\n",
       " 'abortively',\n",
       " 'abortiveness',\n",
       " 'abortus',\n",
       " 'abouchement',\n",
       " 'abound',\n",
       " 'abounder',\n",
       " 'abounding',\n",
       " 'aboundingly',\n",
       " 'about',\n",
       " 'abouts',\n",
       " 'above',\n",
       " 'aboveboard',\n",
       " 'abovedeck',\n",
       " 'aboveground',\n",
       " 'aboveproof',\n",
       " 'abovestairs',\n",
       " 'abox',\n",
       " 'abracadabra',\n",
       " 'abrachia',\n",
       " 'abradant',\n",
       " 'abrade',\n",
       " 'abrader',\n",
       " 'abraid',\n",
       " 'abranchial',\n",
       " 'abranchialism',\n",
       " 'abranchian',\n",
       " 'abranchiate',\n",
       " 'abranchious',\n",
       " 'abrasax',\n",
       " 'abrase',\n",
       " 'abrash',\n",
       " 'abrasiometer',\n",
       " 'abrasion',\n",
       " 'abrasive',\n",
       " 'abrastol',\n",
       " 'abraum',\n",
       " 'abraxas',\n",
       " 'abreact',\n",
       " 'abreaction',\n",
       " 'abreast',\n",
       " 'abrenounce',\n",
       " 'abret',\n",
       " 'abrico',\n",
       " 'abridge',\n",
       " 'abridgeable',\n",
       " 'abridged',\n",
       " 'abridgedly',\n",
       " 'abridger',\n",
       " 'abridgment',\n",
       " 'abrim',\n",
       " 'abrin',\n",
       " 'abristle',\n",
       " 'abroach',\n",
       " 'abroad',\n",
       " 'abrocome',\n",
       " 'abrogable',\n",
       " 'abrogate',\n",
       " 'abrogation',\n",
       " 'abrogative',\n",
       " 'abrogator',\n",
       " 'abrook',\n",
       " 'abrotanum',\n",
       " 'abrotine',\n",
       " 'abrupt',\n",
       " 'abruptedly',\n",
       " 'abruption',\n",
       " 'abruptly',\n",
       " 'abruptness',\n",
       " 'absampere',\n",
       " 'absarokite',\n",
       " 'abscess',\n",
       " 'abscessed',\n",
       " 'abscession',\n",
       " 'abscessroot',\n",
       " 'abscind',\n",
       " 'abscise',\n",
       " 'abscision',\n",
       " 'absciss',\n",
       " 'abscissa',\n",
       " 'abscissae',\n",
       " 'abscisse',\n",
       " 'abscission',\n",
       " 'absconce',\n",
       " 'abscond',\n",
       " 'absconded',\n",
       " 'abscondedly',\n",
       " 'abscondence',\n",
       " 'absconder',\n",
       " 'absconsa',\n",
       " 'abscoulomb',\n",
       " 'absence',\n",
       " 'absent',\n",
       " 'absentation',\n",
       " 'absentee',\n",
       " 'absenteeism',\n",
       " 'absenteeship',\n",
       " 'absenter',\n",
       " 'absently',\n",
       " 'absentment',\n",
       " 'absentmindedly',\n",
       " 'absentness',\n",
       " 'absfarad',\n",
       " 'abshenry',\n",
       " 'absinthe',\n",
       " 'absinthial',\n",
       " 'absinthian',\n",
       " 'absinthiate',\n",
       " 'absinthic',\n",
       " 'absinthin',\n",
       " 'absinthine',\n",
       " 'absinthism',\n",
       " 'absinthismic',\n",
       " 'absinthium',\n",
       " 'absinthol',\n",
       " 'absit',\n",
       " 'absmho',\n",
       " 'absohm',\n",
       " 'absolute',\n",
       " 'absolutely',\n",
       " 'absoluteness',\n",
       " 'absolution',\n",
       " 'absolutism',\n",
       " 'absolutist',\n",
       " 'absolutistic',\n",
       " 'absolutistically',\n",
       " 'absolutive',\n",
       " 'absolutization',\n",
       " 'absolutize',\n",
       " 'absolutory',\n",
       " 'absolvable',\n",
       " 'absolvatory',\n",
       " 'absolve',\n",
       " 'absolvent',\n",
       " 'absolver',\n",
       " 'absolvitor',\n",
       " 'absolvitory',\n",
       " 'absonant',\n",
       " 'absonous',\n",
       " 'absorb',\n",
       " 'absorbability',\n",
       " 'absorbable',\n",
       " 'absorbed',\n",
       " 'absorbedly',\n",
       " 'absorbedness',\n",
       " 'absorbefacient',\n",
       " 'absorbency',\n",
       " 'absorbent',\n",
       " 'absorber',\n",
       " 'absorbing',\n",
       " 'absorbingly',\n",
       " 'absorbition',\n",
       " 'absorpt',\n",
       " 'absorptance',\n",
       " 'absorptiometer',\n",
       " 'absorptiometric',\n",
       " 'absorption',\n",
       " 'absorptive',\n",
       " 'absorptively',\n",
       " 'absorptiveness',\n",
       " 'absorptivity',\n",
       " 'absquatulate',\n",
       " 'abstain',\n",
       " 'abstainer',\n",
       " 'abstainment',\n",
       " 'abstemious',\n",
       " 'abstemiously',\n",
       " 'abstemiousness',\n",
       " 'abstention',\n",
       " 'abstentionist',\n",
       " 'abstentious',\n",
       " 'absterge',\n",
       " 'abstergent',\n",
       " 'abstersion',\n",
       " 'abstersive',\n",
       " 'abstersiveness',\n",
       " 'abstinence',\n",
       " 'abstinency',\n",
       " 'abstinent',\n",
       " 'abstinential',\n",
       " 'abstinently',\n",
       " 'abstract',\n",
       " 'abstracted',\n",
       " 'abstractedly',\n",
       " 'abstractedness',\n",
       " 'abstracter',\n",
       " 'abstraction',\n",
       " 'abstractional',\n",
       " 'abstractionism',\n",
       " 'abstractionist',\n",
       " 'abstractitious',\n",
       " 'abstractive',\n",
       " 'abstractively',\n",
       " 'abstractiveness',\n",
       " 'abstractly',\n",
       " 'abstractness',\n",
       " 'abstractor',\n",
       " 'abstrahent',\n",
       " 'abstricted',\n",
       " 'abstriction',\n",
       " 'abstruse',\n",
       " 'abstrusely',\n",
       " 'abstruseness',\n",
       " 'abstrusion',\n",
       " 'abstrusity',\n",
       " 'absume',\n",
       " 'absumption',\n",
       " 'absurd',\n",
       " 'absurdity',\n",
       " 'absurdly',\n",
       " 'absurdness',\n",
       " 'absvolt',\n",
       " 'abterminal',\n",
       " 'abthain',\n",
       " 'abthainrie',\n",
       " 'abthainry',\n",
       " 'abthanage',\n",
       " 'abu',\n",
       " 'abucco',\n",
       " 'abulia',\n",
       " 'abulic',\n",
       " 'abulomania',\n",
       " 'abuna',\n",
       " 'abundance',\n",
       " 'abundancy',\n",
       " 'abundant',\n",
       " 'abundantly',\n",
       " 'abura',\n",
       " 'aburabozu',\n",
       " 'aburban',\n",
       " 'aburst',\n",
       " 'aburton',\n",
       " 'abusable',\n",
       " 'abuse',\n",
       " 'abusedly',\n",
       " 'abusee',\n",
       " 'abuseful',\n",
       " 'abusefully',\n",
       " 'abusefulness',\n",
       " 'abuser',\n",
       " 'abusion',\n",
       " 'abusious',\n",
       " 'abusive',\n",
       " 'abusively',\n",
       " 'abusiveness',\n",
       " 'abut',\n",
       " 'abutment',\n",
       " 'abuttal',\n",
       " 'abutter',\n",
       " 'abutting',\n",
       " 'abuzz',\n",
       " 'abvolt',\n",
       " 'abwab',\n",
       " 'aby',\n",
       " 'abysm',\n",
       " 'abysmal',\n",
       " 'abysmally',\n",
       " 'abyss',\n",
       " 'abyssal',\n",
       " 'abyssobenthonic',\n",
       " 'abyssolith',\n",
       " 'abyssopelagic',\n",
       " 'acacatechin',\n",
       " 'acacatechol',\n",
       " 'acacetin',\n",
       " 'acaciin',\n",
       " 'acacin',\n",
       " 'academe',\n",
       " 'academial',\n",
       " 'academian',\n",
       " 'academic',\n",
       " 'academical',\n",
       " 'academically',\n",
       " 'academicals',\n",
       " 'academician',\n",
       " 'academicism',\n",
       " 'academism',\n",
       " 'academist',\n",
       " 'academite',\n",
       " 'academization',\n",
       " 'academize',\n",
       " 'academy',\n",
       " 'acadialite',\n",
       " 'acajou',\n",
       " 'acaleph',\n",
       " 'acalephan',\n",
       " 'acalephoid',\n",
       " 'acalycal',\n",
       " 'acalycine',\n",
       " 'acalycinous',\n",
       " 'acalyculate',\n",
       " 'acalyptrate',\n",
       " 'acampsia',\n",
       " 'acana',\n",
       " 'acanaceous',\n",
       " 'acanonical',\n",
       " 'acanth',\n",
       " 'acantha',\n",
       " 'acanthaceous',\n",
       " 'acanthad',\n",
       " 'acanthial',\n",
       " 'acanthin',\n",
       " 'acanthine',\n",
       " 'acanthion',\n",
       " 'acanthite',\n",
       " 'acanthocarpous',\n",
       " 'acanthocephalan',\n",
       " 'acanthocephalous',\n",
       " 'acanthocladous',\n",
       " 'acanthodean',\n",
       " 'acanthodian',\n",
       " 'acanthoid',\n",
       " 'acanthological',\n",
       " 'acanthology',\n",
       " 'acantholysis',\n",
       " 'acanthoma',\n",
       " 'acanthon',\n",
       " 'acanthophorous',\n",
       " 'acanthopod',\n",
       " 'acanthopodous',\n",
       " 'acanthopomatous',\n",
       " 'acanthopore',\n",
       " 'acanthopteran',\n",
       " 'acanthopterous',\n",
       " 'acanthopterygian',\n",
       " 'acanthosis',\n",
       " 'acanthous',\n",
       " 'acanthus',\n",
       " 'acapnia',\n",
       " 'acapnial',\n",
       " 'acapsular',\n",
       " 'acapu',\n",
       " 'acapulco',\n",
       " 'acara',\n",
       " 'acardia',\n",
       " 'acardiac',\n",
       " 'acari',\n",
       " 'acarian',\n",
       " 'acariasis',\n",
       " 'acaricidal',\n",
       " 'acaricide',\n",
       " 'acarid',\n",
       " 'acaridean',\n",
       " 'acaridomatium',\n",
       " 'acariform',\n",
       " 'acarine',\n",
       " 'acarinosis',\n",
       " 'acarocecidium',\n",
       " 'acarodermatitis',\n",
       " 'acaroid',\n",
       " 'acarol',\n",
       " 'acarologist',\n",
       " 'acarology',\n",
       " 'acarophilous',\n",
       " 'acarophobia',\n",
       " 'acarotoxic',\n",
       " 'acarpelous',\n",
       " 'acarpous',\n",
       " 'acatalectic',\n",
       " 'acatalepsia',\n",
       " 'acatalepsy',\n",
       " 'acataleptic',\n",
       " 'acatallactic',\n",
       " 'acatamathesia',\n",
       " 'acataphasia',\n",
       " 'acataposis',\n",
       " 'acatastasia',\n",
       " 'acatastatic',\n",
       " 'acate',\n",
       " 'acategorical',\n",
       " 'acatery',\n",
       " 'acatharsia',\n",
       " 'acatharsy',\n",
       " 'acatholic',\n",
       " 'acaudal',\n",
       " 'acaudate',\n",
       " 'acaulescent',\n",
       " 'acauline',\n",
       " 'acaulose',\n",
       " 'acaulous',\n",
       " 'acca',\n",
       " 'accede',\n",
       " 'accedence',\n",
       " 'acceder',\n",
       " 'accelerable',\n",
       " 'accelerando',\n",
       " 'accelerant',\n",
       " 'accelerate',\n",
       " 'accelerated',\n",
       " 'acceleratedly',\n",
       " 'acceleration',\n",
       " 'accelerative',\n",
       " 'accelerator',\n",
       " 'acceleratory',\n",
       " 'accelerograph',\n",
       " 'accelerometer',\n",
       " 'accend',\n",
       " 'accendibility',\n",
       " 'accendible',\n",
       " 'accension',\n",
       " 'accensor',\n",
       " 'accent',\n",
       " 'accentless',\n",
       " 'accentor',\n",
       " 'accentuable',\n",
       " 'accentual',\n",
       " 'accentuality',\n",
       " 'accentually',\n",
       " 'accentuate',\n",
       " 'accentuation',\n",
       " 'accentuator',\n",
       " 'accentus',\n",
       " 'accept',\n",
       " 'acceptability',\n",
       " 'acceptable',\n",
       " 'acceptableness',\n",
       " 'acceptably',\n",
       " 'acceptance',\n",
       " 'acceptancy',\n",
       " 'acceptant',\n",
       " 'acceptation',\n",
       " 'accepted',\n",
       " 'acceptedly',\n",
       " 'accepter',\n",
       " 'acceptilate',\n",
       " 'acceptilation',\n",
       " 'acception',\n",
       " 'acceptive',\n",
       " 'acceptor',\n",
       " 'acceptress',\n",
       " 'accerse',\n",
       " 'accersition',\n",
       " 'accersitor',\n",
       " 'access',\n",
       " 'accessarily',\n",
       " 'accessariness',\n",
       " 'accessary',\n",
       " 'accessaryship',\n",
       " 'accessibility',\n",
       " 'accessible',\n",
       " 'accessibly',\n",
       " 'accession',\n",
       " 'accessional',\n",
       " 'accessioner',\n",
       " 'accessive',\n",
       " 'accessively',\n",
       " 'accessless',\n",
       " 'accessorial',\n",
       " 'accessorily',\n",
       " 'accessoriness',\n",
       " 'accessorius',\n",
       " 'accessory',\n",
       " 'accidence',\n",
       " 'accidency',\n",
       " 'accident',\n",
       " 'accidental',\n",
       " 'accidentalism',\n",
       " 'accidentalist',\n",
       " 'accidentality',\n",
       " 'accidentally',\n",
       " 'accidentalness',\n",
       " 'accidented',\n",
       " 'accidential',\n",
       " 'accidentiality',\n",
       " 'accidently',\n",
       " 'accidia',\n",
       " 'accidie',\n",
       " 'accinge',\n",
       " 'accipient',\n",
       " 'accipitral',\n",
       " 'accipitrary',\n",
       " 'accipitrine',\n",
       " 'accismus',\n",
       " 'accite',\n",
       " 'acclaim',\n",
       " 'acclaimable',\n",
       " 'acclaimer',\n",
       " 'acclamation',\n",
       " 'acclamator',\n",
       " 'acclamatory',\n",
       " 'acclimatable',\n",
       " 'acclimatation',\n",
       " 'acclimate',\n",
       " 'acclimatement',\n",
       " 'acclimation',\n",
       " 'acclimatizable',\n",
       " 'acclimatization',\n",
       " 'acclimatize',\n",
       " 'acclimatizer',\n",
       " 'acclimature',\n",
       " 'acclinal',\n",
       " 'acclinate',\n",
       " 'acclivitous',\n",
       " 'acclivity',\n",
       " 'acclivous',\n",
       " 'accloy',\n",
       " 'accoast',\n",
       " 'accoil',\n",
       " 'accolade',\n",
       " 'accoladed',\n",
       " 'accolated',\n",
       " 'accolent',\n",
       " 'accolle',\n",
       " 'accombination',\n",
       " 'accommodable',\n",
       " 'accommodableness',\n",
       " 'accommodate',\n",
       " 'accommodately',\n",
       " 'accommodateness',\n",
       " 'accommodating',\n",
       " 'accommodatingly',\n",
       " 'accommodation',\n",
       " 'accommodational',\n",
       " 'accommodative',\n",
       " 'accommodativeness',\n",
       " 'accommodator',\n",
       " 'accompanier',\n",
       " 'accompaniment',\n",
       " 'accompanimental',\n",
       " 'accompanist',\n",
       " 'accompany',\n",
       " 'accompanyist',\n",
       " 'accompletive',\n",
       " 'accomplice',\n",
       " 'accompliceship',\n",
       " 'accomplicity',\n",
       " 'accomplish',\n",
       " 'accomplishable',\n",
       " 'accomplished',\n",
       " 'accomplisher',\n",
       " 'accomplishment',\n",
       " 'accomplisht',\n",
       " 'accompt',\n",
       " 'accord',\n",
       " 'accordable',\n",
       " 'accordance',\n",
       " 'accordancy',\n",
       " 'accordant',\n",
       " 'accordantly',\n",
       " 'accorder',\n",
       " 'according',\n",
       " 'accordingly',\n",
       " 'accordion',\n",
       " 'accordionist',\n",
       " 'accorporate',\n",
       " 'accorporation',\n",
       " 'accost',\n",
       " 'accostable',\n",
       " 'accosted',\n",
       " 'accouche',\n",
       " 'accouchement',\n",
       " 'accoucheur',\n",
       " 'accoucheuse',\n",
       " 'account',\n",
       " 'accountability',\n",
       " 'accountable',\n",
       " 'accountableness',\n",
       " 'accountably',\n",
       " 'accountancy',\n",
       " 'accountant',\n",
       " 'accountantship',\n",
       " 'accounting',\n",
       " 'accountment',\n",
       " 'accouple',\n",
       " 'accouplement',\n",
       " 'accouter',\n",
       " 'accouterment',\n",
       " 'accoy',\n",
       " 'accredit',\n",
       " 'accreditate',\n",
       " 'accreditation',\n",
       " 'accredited',\n",
       " 'accreditment',\n",
       " 'accrementitial',\n",
       " 'accrementition',\n",
       " 'accresce',\n",
       " 'accrescence',\n",
       " 'accrescent',\n",
       " 'accretal',\n",
       " 'accrete',\n",
       " 'accretion',\n",
       " 'accretionary',\n",
       " 'accretive',\n",
       " 'accroach',\n",
       " 'accroides',\n",
       " 'accrual',\n",
       " 'accrue',\n",
       " 'accruement',\n",
       " 'accruer',\n",
       " 'accubation',\n",
       " 'accubitum',\n",
       " 'accubitus',\n",
       " 'accultural',\n",
       " 'acculturate',\n",
       " 'acculturation',\n",
       " 'acculturize',\n",
       " 'accumbency',\n",
       " 'accumbent',\n",
       " 'accumber',\n",
       " 'accumulable',\n",
       " 'accumulate',\n",
       " 'accumulation',\n",
       " 'accumulativ',\n",
       " 'accumulative',\n",
       " 'accumulatively',\n",
       " 'accumulativeness',\n",
       " 'accumulator',\n",
       " 'accuracy',\n",
       " 'accurate',\n",
       " 'accurately',\n",
       " 'accurateness',\n",
       " 'accurse',\n",
       " 'accursed',\n",
       " 'accursedly',\n",
       " 'accursedness',\n",
       " 'accusable',\n",
       " 'accusably',\n",
       " 'accusal',\n",
       " 'accusant',\n",
       " 'accusation',\n",
       " 'accusatival',\n",
       " 'accusative',\n",
       " 'accusatively',\n",
       " 'accusatorial',\n",
       " 'accusatorially',\n",
       " 'accusatory',\n",
       " 'accusatrix',\n",
       " 'accuse',\n",
       " 'accused',\n",
       " 'accuser',\n",
       " 'accusingly',\n",
       " 'accusive',\n",
       " 'accustom',\n",
       " 'accustomed',\n",
       " 'accustomedly',\n",
       " 'accustomedness',\n",
       " 'ace',\n",
       " 'aceacenaphthene',\n",
       " 'aceanthrene',\n",
       " 'aceanthrenequinone',\n",
       " 'acecaffine',\n",
       " 'aceconitic',\n",
       " 'acedia',\n",
       " 'acediamine',\n",
       " 'acediast',\n",
       " 'acedy',\n",
       " 'acenaphthene',\n",
       " 'acenaphthenyl',\n",
       " 'acenaphthylene',\n",
       " 'acentric',\n",
       " 'acentrous',\n",
       " 'aceologic',\n",
       " 'aceology',\n",
       " 'acephal',\n",
       " 'acephalan',\n",
       " 'acephalia',\n",
       " 'acephaline',\n",
       " 'acephalism',\n",
       " 'acephalist',\n",
       " ...]"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import re\n",
    "wordlist = [w for w in nltk.corpus.words.words(\"en\") if w.islower()]\n",
    "wordlist"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1、使用基本的元字符"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['abaissed',\n",
       " 'abandoned',\n",
       " 'abased',\n",
       " 'abashed',\n",
       " 'abatised',\n",
       " 'abed',\n",
       " 'aborted',\n",
       " 'abridged',\n",
       " 'abscessed',\n",
       " 'absconded',\n",
       " 'absorbed',\n",
       " 'abstracted',\n",
       " 'abstricted',\n",
       " 'accelerated',\n",
       " 'accepted',\n",
       " 'accidented',\n",
       " 'accoladed',\n",
       " 'accolated',\n",
       " 'accomplished',\n",
       " 'accosted',\n",
       " 'accredited',\n",
       " 'accursed',\n",
       " 'accused',\n",
       " 'accustomed',\n",
       " 'acetated',\n",
       " 'acheweed',\n",
       " 'aciculated',\n",
       " 'aciliated',\n",
       " 'acknowledged',\n",
       " 'acorned',\n",
       " 'acquainted',\n",
       " 'acquired',\n",
       " 'acquisited',\n",
       " 'acred',\n",
       " 'aculeated',\n",
       " 'addebted',\n",
       " 'added',\n",
       " 'addicted',\n",
       " 'addlebrained',\n",
       " 'addleheaded',\n",
       " 'addlepated',\n",
       " 'addorsed',\n",
       " 'adempted',\n",
       " 'adfected',\n",
       " 'adjoined',\n",
       " 'admired',\n",
       " 'admitted',\n",
       " 'adnexed',\n",
       " 'adopted',\n",
       " 'adossed',\n",
       " 'adreamed',\n",
       " 'adscripted',\n",
       " 'aduncated',\n",
       " 'advanced',\n",
       " 'advised',\n",
       " 'aeried',\n",
       " 'aethered',\n",
       " 'afeared',\n",
       " 'affected',\n",
       " 'affectioned',\n",
       " 'affined',\n",
       " 'afflicted',\n",
       " 'affricated',\n",
       " 'affrighted',\n",
       " 'affronted',\n",
       " 'aforenamed',\n",
       " 'afterfeed',\n",
       " 'aftershafted',\n",
       " 'afterthoughted',\n",
       " 'afterwitted',\n",
       " 'agazed',\n",
       " 'aged',\n",
       " 'agglomerated',\n",
       " 'aggrieved',\n",
       " 'agminated',\n",
       " 'agnamed',\n",
       " 'agonied',\n",
       " 'agreed',\n",
       " 'agueweed',\n",
       " 'ahungered',\n",
       " 'aiguilletted',\n",
       " 'ailweed',\n",
       " 'airbrained',\n",
       " 'airified',\n",
       " 'aiseweed',\n",
       " 'aisled',\n",
       " 'alarmed',\n",
       " 'alated',\n",
       " 'alimonied',\n",
       " 'aliped',\n",
       " 'alleyed',\n",
       " 'allied',\n",
       " 'alligatored',\n",
       " 'allseed',\n",
       " 'almsdeed',\n",
       " 'aloed',\n",
       " 'altared',\n",
       " 'alveolated',\n",
       " 'amazed',\n",
       " 'ameed',\n",
       " 'amiced',\n",
       " 'amphitheatered',\n",
       " 'ampullated',\n",
       " 'amused',\n",
       " 'anchored',\n",
       " 'angled',\n",
       " 'anguiped',\n",
       " 'anguished',\n",
       " 'angulated',\n",
       " 'angulinerved',\n",
       " 'anhungered',\n",
       " 'animated',\n",
       " 'aniseed',\n",
       " 'annodated',\n",
       " 'annulated',\n",
       " 'anomaliped',\n",
       " 'anserated',\n",
       " 'anteflected',\n",
       " 'anteflexed',\n",
       " 'antimoniated',\n",
       " 'antimoniureted',\n",
       " 'antimoniuretted',\n",
       " 'antiquated',\n",
       " 'antired',\n",
       " 'antiweed',\n",
       " 'antlered',\n",
       " 'apertured',\n",
       " 'apexed',\n",
       " 'apicifixed',\n",
       " 'apiculated',\n",
       " 'apocopated',\n",
       " 'apostrophied',\n",
       " 'appearanced',\n",
       " 'appellatived',\n",
       " 'appendaged',\n",
       " 'appendiculated',\n",
       " 'applied',\n",
       " 'appressed',\n",
       " 'aralkylated',\n",
       " 'arbored',\n",
       " 'arched',\n",
       " 'architraved',\n",
       " 'arcked',\n",
       " 'arcuated',\n",
       " 'ared',\n",
       " 'areolated',\n",
       " 'ariled',\n",
       " 'arillated',\n",
       " 'armchaired',\n",
       " 'armed',\n",
       " 'armied',\n",
       " 'armillated',\n",
       " 'armored',\n",
       " 'armoried',\n",
       " 'arpeggiated',\n",
       " 'arpeggioed',\n",
       " 'arrased',\n",
       " 'arrowed',\n",
       " 'arrowheaded',\n",
       " 'arrowweed',\n",
       " 'arseneted',\n",
       " 'arsenetted',\n",
       " 'arseniureted',\n",
       " 'articled',\n",
       " 'articulated',\n",
       " 'ashamed',\n",
       " 'ashlared',\n",
       " 'ashweed',\n",
       " 'aspersed',\n",
       " 'asphyxied',\n",
       " 'assented',\n",
       " 'assessed',\n",
       " 'assigned',\n",
       " 'assistanted',\n",
       " 'associated',\n",
       " 'assonanced',\n",
       " 'assorted',\n",
       " 'assumed',\n",
       " 'assured',\n",
       " 'asteriated',\n",
       " 'astonied',\n",
       " 'aswooned',\n",
       " 'atrophiated',\n",
       " 'atrophied',\n",
       " 'attached',\n",
       " 'attired',\n",
       " 'attrited',\n",
       " 'augmented',\n",
       " 'aurated',\n",
       " 'auricled',\n",
       " 'auriculated',\n",
       " 'authorized',\n",
       " 'autoinhibited',\n",
       " 'autosensitized',\n",
       " 'autosled',\n",
       " 'averted',\n",
       " 'avowed',\n",
       " 'awearied',\n",
       " 'awned',\n",
       " 'awninged',\n",
       " 'axed',\n",
       " 'axhammered',\n",
       " 'axised',\n",
       " 'axled',\n",
       " 'axseed',\n",
       " 'axweed',\n",
       " 'azoted',\n",
       " 'azured',\n",
       " 'babied',\n",
       " 'babished',\n",
       " 'babyfied',\n",
       " 'baccated',\n",
       " 'backboned',\n",
       " 'backed',\n",
       " 'backhanded',\n",
       " 'backwatered',\n",
       " 'baconweed',\n",
       " 'badgerweed',\n",
       " 'bagged',\n",
       " 'bagwigged',\n",
       " 'baked',\n",
       " 'balanced',\n",
       " 'balconied',\n",
       " 'baldachined',\n",
       " 'baldricked',\n",
       " 'balled',\n",
       " 'ballweed',\n",
       " 'balsamweed',\n",
       " 'balustered',\n",
       " 'balustraded',\n",
       " 'bandannaed',\n",
       " 'banded',\n",
       " 'bandoleered',\n",
       " 'bangled',\n",
       " 'banked',\n",
       " 'bankweed',\n",
       " 'bannered',\n",
       " 'barbated',\n",
       " 'barbed',\n",
       " 'barebacked',\n",
       " 'bareboned',\n",
       " 'barefaced',\n",
       " 'barefooted',\n",
       " 'barehanded',\n",
       " 'bareheaded',\n",
       " 'barelegged',\n",
       " 'barenecked',\n",
       " 'barmybrained',\n",
       " 'barred',\n",
       " 'barreled',\n",
       " 'bartizaned',\n",
       " 'basebred',\n",
       " 'based',\n",
       " 'basehearted',\n",
       " 'basifixed',\n",
       " 'basilweed',\n",
       " 'basined',\n",
       " 'basinerved',\n",
       " 'basqued',\n",
       " 'bastioned',\n",
       " 'bated',\n",
       " 'bathroomed',\n",
       " 'battered',\n",
       " 'batteried',\n",
       " 'battled',\n",
       " 'battlemented',\n",
       " 'bayed',\n",
       " 'bayoneted',\n",
       " 'beached',\n",
       " 'beaded',\n",
       " 'beaked',\n",
       " 'bealtared',\n",
       " 'beamed',\n",
       " 'beanweed',\n",
       " 'beaproned',\n",
       " 'bearded',\n",
       " 'beautied',\n",
       " 'beavered',\n",
       " 'beballed',\n",
       " 'bebannered',\n",
       " 'bebed',\n",
       " 'bebelted',\n",
       " 'bebled',\n",
       " 'bebothered',\n",
       " 'bebouldered',\n",
       " 'bebuttoned',\n",
       " 'becassocked',\n",
       " 'bechained',\n",
       " 'bechignoned',\n",
       " 'becircled',\n",
       " 'becoiffed',\n",
       " 'becombed',\n",
       " 'becousined',\n",
       " 'becrinolined',\n",
       " 'becuffed',\n",
       " 'becurtained',\n",
       " 'becushioned',\n",
       " 'bed',\n",
       " 'bedaggered',\n",
       " 'bedangled',\n",
       " 'bedded',\n",
       " 'bediademed',\n",
       " 'bediamonded',\n",
       " 'beedged',\n",
       " 'beefheaded',\n",
       " 'beeheaded',\n",
       " 'beeswinged',\n",
       " 'beetled',\n",
       " 'beetleheaded',\n",
       " 'beetleweed',\n",
       " 'beeweed',\n",
       " 'befamilied',\n",
       " 'befanned',\n",
       " 'befathered',\n",
       " 'beferned',\n",
       " 'befetished',\n",
       " 'befezzed',\n",
       " 'befilleted',\n",
       " 'befilmed',\n",
       " 'beforested',\n",
       " 'befountained',\n",
       " 'befrocked',\n",
       " 'befrogged',\n",
       " 'befurbelowed',\n",
       " 'befurred',\n",
       " 'begabled',\n",
       " 'begarlanded',\n",
       " 'begartered',\n",
       " 'beggarweed',\n",
       " 'beglobed',\n",
       " 'begoggled',\n",
       " 'begowned',\n",
       " 'behatted',\n",
       " 'behaviored',\n",
       " 'beheadlined',\n",
       " 'behooped',\n",
       " 'beinked',\n",
       " 'bekilted',\n",
       " 'beknived',\n",
       " 'beknotted',\n",
       " 'belaced',\n",
       " 'belated',\n",
       " 'belatticed',\n",
       " 'belavendered',\n",
       " 'beledgered',\n",
       " 'belfried',\n",
       " 'beliked',\n",
       " 'belimousined',\n",
       " 'belled',\n",
       " 'bellied',\n",
       " 'bellmouthed',\n",
       " 'bellweed',\n",
       " 'beloved',\n",
       " 'belozenged',\n",
       " 'belted',\n",
       " 'bemazed',\n",
       " 'bemedaled',\n",
       " 'bemedalled',\n",
       " 'bemitered',\n",
       " 'bemitred',\n",
       " 'bemused',\n",
       " 'bemuslined',\n",
       " 'bended',\n",
       " 'beneaped',\n",
       " 'beneficed',\n",
       " 'beneighbored',\n",
       " 'benempted',\n",
       " 'benighted',\n",
       " 'bennetweed',\n",
       " 'benumbed',\n",
       " 'benweed',\n",
       " 'benzoated',\n",
       " 'benzoinated',\n",
       " 'bepastured',\n",
       " 'bepatched',\n",
       " 'beperiwigged',\n",
       " 'bepewed',\n",
       " 'bepillared',\n",
       " 'bepistoled',\n",
       " 'beplaided',\n",
       " 'beplumed',\n",
       " 'beribanded',\n",
       " 'beribboned',\n",
       " 'beringed',\n",
       " 'beringleted',\n",
       " 'berobed',\n",
       " 'berouged',\n",
       " 'berried',\n",
       " 'berthed',\n",
       " 'beruffed',\n",
       " 'beruffled',\n",
       " 'beshawled',\n",
       " 'besieged',\n",
       " 'beslushed',\n",
       " 'besotted',\n",
       " 'bespecked',\n",
       " 'bespectacled',\n",
       " 'besped',\n",
       " 'bespeed',\n",
       " 'bespelled',\n",
       " 'bespurred',\n",
       " 'bestatued',\n",
       " 'bestayed',\n",
       " 'bestrapped',\n",
       " 'bestubbled',\n",
       " 'besweatered',\n",
       " 'betattered',\n",
       " 'betaxed',\n",
       " 'betowered',\n",
       " 'betrothed',\n",
       " 'betrousered',\n",
       " 'betted',\n",
       " 'betuckered',\n",
       " 'beturbaned',\n",
       " 'betusked',\n",
       " 'betutored',\n",
       " 'betwattled',\n",
       " 'beuniformed',\n",
       " 'beveled',\n",
       " 'bevelled',\n",
       " 'bevesseled',\n",
       " 'bevesselled',\n",
       " 'bevined',\n",
       " 'bevoiled',\n",
       " 'bewaitered',\n",
       " 'bewhiskered',\n",
       " 'bewigged',\n",
       " 'bewildered',\n",
       " 'bewinged',\n",
       " 'bewired',\n",
       " 'bewrathed',\n",
       " 'biangulated',\n",
       " 'biarcuated',\n",
       " 'biarticulated',\n",
       " 'bicarbureted',\n",
       " 'biciliated',\n",
       " 'bicolored',\n",
       " 'bicorned',\n",
       " 'bidented',\n",
       " 'bifanged',\n",
       " 'bifidated',\n",
       " 'biflected',\n",
       " 'biforked',\n",
       " 'biformed',\n",
       " 'bifronted',\n",
       " 'bifurcated',\n",
       " 'bigeminated',\n",
       " 'bighearted',\n",
       " 'bigmouthed',\n",
       " 'bigoted',\n",
       " 'bigwigged',\n",
       " 'bilamellated',\n",
       " 'bilaminated',\n",
       " 'billed',\n",
       " 'bilobated',\n",
       " 'bilobed',\n",
       " 'bilsted',\n",
       " 'bimaculated',\n",
       " 'bimotored',\n",
       " 'bindweed',\n",
       " 'bineweed',\n",
       " 'binominated',\n",
       " 'binucleated',\n",
       " 'biparted',\n",
       " 'bipectinated',\n",
       " 'biped',\n",
       " 'bipennated',\n",
       " 'bipinnated',\n",
       " 'bipinnatiparted',\n",
       " 'bipinnatisected',\n",
       " 'biradiated',\n",
       " 'birdmouthed',\n",
       " 'birdseed',\n",
       " 'birdweed',\n",
       " 'birostrated',\n",
       " 'birthbed',\n",
       " 'bisexed',\n",
       " 'bishopweed',\n",
       " 'bistered',\n",
       " 'bistipuled',\n",
       " 'bisubstituted',\n",
       " 'bitted',\n",
       " 'bitterhearted',\n",
       " 'bitterweed',\n",
       " 'bituberculated',\n",
       " 'bitumed',\n",
       " 'bivalved',\n",
       " 'bivaulted',\n",
       " 'bivocalized',\n",
       " 'blackhearted',\n",
       " 'blackseed',\n",
       " 'blackshirted',\n",
       " 'bladderseed',\n",
       " 'bladderweed',\n",
       " 'bladed',\n",
       " 'blakeberyed',\n",
       " 'blamed',\n",
       " 'blanked',\n",
       " 'blanketed',\n",
       " 'blanketweed',\n",
       " 'blasted',\n",
       " 'bleached',\n",
       " 'bleared',\n",
       " 'bleed',\n",
       " 'blended',\n",
       " 'blessed',\n",
       " 'blighted',\n",
       " 'blinded',\n",
       " 'blindfolded',\n",
       " 'blindweed',\n",
       " 'blinked',\n",
       " 'blinkered',\n",
       " 'blistered',\n",
       " 'blisterweed',\n",
       " 'blithehearted',\n",
       " 'bloated',\n",
       " 'blobbed',\n",
       " 'blocked',\n",
       " 'blockheaded',\n",
       " 'blooded',\n",
       " 'bloodied',\n",
       " 'bloodshed',\n",
       " 'bloodstained',\n",
       " 'bloodweed',\n",
       " 'blossomed',\n",
       " 'blotched',\n",
       " 'bloused',\n",
       " 'blowzed',\n",
       " 'bludgeoned',\n",
       " 'bluebelled',\n",
       " 'bluehearted',\n",
       " 'blueweed',\n",
       " 'blunderheaded',\n",
       " 'blunthearted',\n",
       " 'blurred',\n",
       " 'bobbed',\n",
       " 'bobsled',\n",
       " 'bobtailed',\n",
       " 'bodiced',\n",
       " 'bodied',\n",
       " 'boiled',\n",
       " 'boldhearted',\n",
       " 'bolectioned',\n",
       " 'boled',\n",
       " 'boleweed',\n",
       " 'bolled',\n",
       " 'bombed',\n",
       " 'bonded',\n",
       " 'boned',\n",
       " 'boneheaded',\n",
       " 'bonneted',\n",
       " 'booked',\n",
       " 'booted',\n",
       " 'bootied',\n",
       " 'boozed',\n",
       " 'bordered',\n",
       " 'bordured',\n",
       " 'bosomed',\n",
       " 'bossed',\n",
       " 'bosselated',\n",
       " 'botched',\n",
       " 'botherheaded',\n",
       " 'bothsided',\n",
       " 'bottled',\n",
       " 'bottomed',\n",
       " 'boughed',\n",
       " 'bounded',\n",
       " 'bountied',\n",
       " 'bowed',\n",
       " 'boweled',\n",
       " 'bowlegged',\n",
       " 'bowstringed',\n",
       " 'braced',\n",
       " 'braceleted',\n",
       " 'brackened',\n",
       " 'bracted',\n",
       " 'braided',\n",
       " 'brambled',\n",
       " 'branched',\n",
       " 'branded',\n",
       " 'brandied',\n",
       " 'brangled',\n",
       " 'bravehearted',\n",
       " 'brawned',\n",
       " 'brazenfaced',\n",
       " 'breasted',\n",
       " 'breastweed',\n",
       " 'breathed',\n",
       " 'brecciated',\n",
       " 'bred',\n",
       " 'breeched',\n",
       " 'breed',\n",
       " 'breviped',\n",
       " 'bridebed',\n",
       " 'brideweed',\n",
       " 'bridged',\n",
       " 'bridled',\n",
       " 'briered',\n",
       " 'brimmed',\n",
       " 'bristled',\n",
       " 'broadhearted',\n",
       " 'brocaded',\n",
       " 'brocked',\n",
       " 'brokenhearted',\n",
       " 'bromoiodized',\n",
       " 'bronzed',\n",
       " 'brooked',\n",
       " 'brookweed',\n",
       " 'broomweed',\n",
       " 'broozled',\n",
       " 'browed',\n",
       " 'brownweed',\n",
       " 'bruckled',\n",
       " 'brushed',\n",
       " 'buboed',\n",
       " 'bucked',\n",
       " 'buckled',\n",
       " 'buckskinned',\n",
       " 'buffed',\n",
       " 'bugled',\n",
       " 'bugleweed',\n",
       " 'bugseed',\n",
       " 'bugweed',\n",
       " 'bulbed',\n",
       " 'bulked',\n",
       " 'bulkheaded',\n",
       " 'bullated',\n",
       " 'bulldogged',\n",
       " 'bulleted',\n",
       " 'bulletheaded',\n",
       " 'bullheaded',\n",
       " 'bullweed',\n",
       " 'bummed',\n",
       " 'bundlerooted',\n",
       " 'bundweed',\n",
       " 'bunted',\n",
       " 'buried',\n",
       " 'burled',\n",
       " 'burned',\n",
       " 'burnoosed',\n",
       " 'burntweed',\n",
       " 'burred',\n",
       " 'burroweed',\n",
       " 'burseed',\n",
       " 'burweed',\n",
       " 'bushed',\n",
       " 'busied',\n",
       " 'busked',\n",
       " 'buskined',\n",
       " 'busted',\n",
       " 'bustled',\n",
       " 'busybodied',\n",
       " 'buttered',\n",
       " 'butterfingered',\n",
       " 'butterweed',\n",
       " 'butteryfingered',\n",
       " 'buttocked',\n",
       " 'buttoned',\n",
       " 'buttonweed',\n",
       " 'cabled',\n",
       " 'caboshed',\n",
       " 'caddiced',\n",
       " 'caddised',\n",
       " 'cadenced',\n",
       " 'cadweed',\n",
       " 'caftaned',\n",
       " 'caged',\n",
       " 'cairned',\n",
       " 'caissoned',\n",
       " 'calced',\n",
       " 'calcified',\n",
       " 'calcined',\n",
       " 'calculated',\n",
       " 'calibered',\n",
       " 'calicoed',\n",
       " 'caligated',\n",
       " 'calpacked',\n",
       " 'calved',\n",
       " 'calycled',\n",
       " 'calyculated',\n",
       " 'camailed',\n",
       " 'camerated',\n",
       " 'cammed',\n",
       " 'campanulated',\n",
       " 'campshed',\n",
       " 'camused',\n",
       " 'canaliculated',\n",
       " 'cancellated',\n",
       " 'cancered',\n",
       " 'cancerweed',\n",
       " 'candied',\n",
       " 'candlelighted',\n",
       " 'candlesticked',\n",
       " 'candyweed',\n",
       " 'canioned',\n",
       " 'cankered',\n",
       " 'cankerweed',\n",
       " 'canned',\n",
       " 'cannelated',\n",
       " 'cannelured',\n",
       " 'cannoned',\n",
       " 'cannulated',\n",
       " 'canted',\n",
       " 'cantilevered',\n",
       " 'cantoned',\n",
       " 'cantred',\n",
       " 'caped',\n",
       " 'capernoited',\n",
       " 'capeweed',\n",
       " 'capitaled',\n",
       " 'capitated',\n",
       " 'capped',\n",
       " 'capriped',\n",
       " 'capsulated',\n",
       " 'capuched',\n",
       " 'carapaced',\n",
       " 'carbolated',\n",
       " 'carboyed',\n",
       " 'carbuncled',\n",
       " 'carcaneted',\n",
       " 'carded',\n",
       " 'carinated',\n",
       " 'carkled',\n",
       " 'carnaged',\n",
       " 'carnationed',\n",
       " 'carpetweed',\n",
       " 'carried',\n",
       " 'carrotweed',\n",
       " 'carucated',\n",
       " 'carunculated',\n",
       " 'cased',\n",
       " 'casemated',\n",
       " 'casemented',\n",
       " 'caseweed',\n",
       " 'casqued',\n",
       " 'castellated',\n",
       " 'castled',\n",
       " 'castorized',\n",
       " 'catamited',\n",
       " 'cataracted',\n",
       " 'catarrhed',\n",
       " 'catchweed',\n",
       " 'catenated',\n",
       " 'caterpillared',\n",
       " 'catfaced',\n",
       " 'catfooted',\n",
       " 'cathedraled',\n",
       " 'caudated',\n",
       " 'caverned',\n",
       " 'cavitied',\n",
       " 'cayenned',\n",
       " 'cedared',\n",
       " 'ceilinged',\n",
       " 'celebrated',\n",
       " 'cellated',\n",
       " 'celled',\n",
       " 'cellulated',\n",
       " 'celluloided',\n",
       " 'centered',\n",
       " 'centriffed',\n",
       " 'centuried',\n",
       " 'cerated',\n",
       " 'cered',\n",
       " 'certified',\n",
       " 'chafeweed',\n",
       " 'chaffseed',\n",
       " 'chaffweed',\n",
       " 'chafted',\n",
       " 'chained',\n",
       " 'chaliced',\n",
       " 'chambered',\n",
       " 'chamberleted',\n",
       " 'chamberletted',\n",
       " 'chanceled',\n",
       " 'channeled',\n",
       " 'channelled',\n",
       " 'chaped',\n",
       " 'chapleted',\n",
       " 'chapournetted',\n",
       " 'chapped',\n",
       " 'charioted',\n",
       " 'charqued',\n",
       " 'chartered',\n",
       " 'chasmed',\n",
       " 'chasteweed',\n",
       " 'chasubled',\n",
       " 'checked',\n",
       " 'checkered',\n",
       " 'checkrowed',\n",
       " 'cheered',\n",
       " 'cheliped',\n",
       " 'cherried',\n",
       " 'chickenbreasted',\n",
       " 'chickenhearted',\n",
       " 'chickenweed',\n",
       " 'chickweed',\n",
       " 'chicqued',\n",
       " 'chiggerweed',\n",
       " 'chignoned',\n",
       " 'childbed',\n",
       " 'childed',\n",
       " 'chilled',\n",
       " 'chined',\n",
       " 'chinned',\n",
       " 'chipped',\n",
       " 'chiseled',\n",
       " 'chitinized',\n",
       " 'chokered',\n",
       " 'chokeweed',\n",
       " 'cholterheaded',\n",
       " 'chopped',\n",
       " 'choppered',\n",
       " 'chorded',\n",
       " 'chowderheaded',\n",
       " 'christened',\n",
       " 'chubbed',\n",
       " 'chuckleheaded',\n",
       " 'churchified',\n",
       " 'churled',\n",
       " 'ciliated',\n",
       " 'cingulated',\n",
       " 'cinnamoned',\n",
       " 'cinquefoiled',\n",
       " 'circled',\n",
       " 'circumscribed',\n",
       " 'circumstanced',\n",
       " 'cirrated',\n",
       " 'cirrhosed',\n",
       " 'cirriped',\n",
       " 'cisted',\n",
       " 'citied',\n",
       " 'citified',\n",
       " 'citrated',\n",
       " 'civilized',\n",
       " 'clammed',\n",
       " 'clammyweed',\n",
       " 'clanned',\n",
       " 'clapped',\n",
       " 'classed',\n",
       " 'classified',\n",
       " 'clavated',\n",
       " 'clavellated',\n",
       " 'clawed',\n",
       " 'claybrained',\n",
       " 'clayweed',\n",
       " 'cleaded',\n",
       " 'cleanhanded',\n",
       " 'cleanhearted',\n",
       " 'clearheaded',\n",
       " 'clearhearted',\n",
       " 'clearweed',\n",
       " 'cled',\n",
       " 'cleeked',\n",
       " 'clefted',\n",
       " 'clerestoried',\n",
       " 'cliented',\n",
       " 'cliffed',\n",
       " 'cliffweed',\n",
       " 'clipped',\n",
       " 'cloaked',\n",
       " 'clocked',\n",
       " 'clodpated',\n",
       " 'cloistered',\n",
       " 'closed',\n",
       " 'closefisted',\n",
       " 'closehanded',\n",
       " 'closehearted',\n",
       " 'closemouthed',\n",
       " 'clotweed',\n",
       " 'clouded',\n",
       " 'clouted',\n",
       " 'clovered',\n",
       " 'clubbed',\n",
       " 'clubfisted',\n",
       " 'clubfooted',\n",
       " 'clubweed',\n",
       " 'clustered',\n",
       " 'coaged',\n",
       " 'coaggregated',\n",
       " 'coated',\n",
       " 'coattailed',\n",
       " 'cobbed',\n",
       " 'cocashweed',\n",
       " 'cochleated',\n",
       " 'cockaded',\n",
       " 'cocked',\n",
       " 'cockeyed',\n",
       " 'cockled',\n",
       " 'cockneybred',\n",
       " 'cockscombed',\n",
       " 'cockweed',\n",
       " 'codheaded',\n",
       " 'coed',\n",
       " 'coelongated',\n",
       " 'coembedded',\n",
       " 'coequated',\n",
       " 'coexpanded',\n",
       " 'coffeeweed',\n",
       " 'cogged',\n",
       " 'coifed',\n",
       " 'coiled',\n",
       " 'coldhearted',\n",
       " 'coleseed',\n",
       " 'colicweed',\n",
       " 'collared',\n",
       " 'collected',\n",
       " 'collied',\n",
       " 'colloped',\n",
       " 'colonnaded',\n",
       " 'colored',\n",
       " 'columnated',\n",
       " 'columned',\n",
       " 'combed',\n",
       " 'combined',\n",
       " 'compacted',\n",
       " 'complected',\n",
       " 'complexioned',\n",
       " 'complicated',\n",
       " 'componed',\n",
       " 'componented',\n",
       " 'composed',\n",
       " 'compressed',\n",
       " 'comprised',\n",
       " 'compulsed',\n",
       " 'conamed',\n",
       " 'concamerated',\n",
       " 'concealed',\n",
       " 'conceded',\n",
       " 'conceited',\n",
       " 'concentrated',\n",
       " 'concerned',\n",
       " 'concerted',\n",
       " 'conched',\n",
       " 'conchyliated',\n",
       " 'condemned',\n",
       " 'condensed',\n",
       " 'conditioned',\n",
       " 'conduplicated',\n",
       " 'coned',\n",
       " 'confated',\n",
       " 'conferted',\n",
       " 'confined',\n",
       " 'confirmed',\n",
       " 'conflated',\n",
       " 'confounded',\n",
       " 'confused',\n",
       " 'congested',\n",
       " 'conjoined',\n",
       " 'conjugated',\n",
       " 'connected',\n",
       " 'conred',\n",
       " 'consecrated',\n",
       " 'considered',\n",
       " 'consolidated',\n",
       " 'constrained',\n",
       " 'constricted',\n",
       " 'consumpted',\n",
       " 'contagioned',\n",
       " 'contented',\n",
       " 'contextured',\n",
       " 'continued',\n",
       " 'contorted',\n",
       " 'contortioned',\n",
       " 'contracted',\n",
       " 'contractured',\n",
       " 'contusioned',\n",
       " 'converted',\n",
       " 'convexed',\n",
       " 'convinced',\n",
       " 'convoluted',\n",
       " 'coolheaded',\n",
       " 'coolweed',\n",
       " 'copied',\n",
       " 'copleased',\n",
       " 'copped',\n",
       " 'coppernosed',\n",
       " 'copperytailed',\n",
       " 'coppiced',\n",
       " 'coppled',\n",
       " 'copsewooded',\n",
       " 'copygraphed',\n",
       " 'coraled',\n",
       " 'corded',\n",
       " 'corduroyed',\n",
       " 'cored',\n",
       " 'coreflexed',\n",
       " 'corked',\n",
       " 'cornered',\n",
       " 'cornified',\n",
       " 'cornuated',\n",
       " 'cornuted',\n",
       " 'corollated',\n",
       " 'coronaled',\n",
       " 'coronated',\n",
       " 'coroneted',\n",
       " 'coronetted',\n",
       " 'corpusculated',\n",
       " 'corrected',\n",
       " 'correlated',\n",
       " 'corridored',\n",
       " ...]"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[w for w in wordlist if re.search(\"ed$\", w)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['abjectly',\n",
       " 'adjuster',\n",
       " 'dejected',\n",
       " 'dejectly',\n",
       " 'injector',\n",
       " 'majestic',\n",
       " 'objectee',\n",
       " 'objector',\n",
       " 'rejecter',\n",
       " 'rejector',\n",
       " 'unjilted',\n",
       " 'unjolted',\n",
       " 'unjustly']"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[w for w in wordlist if re.search(\"^..j..t..$\", w)] # 匹配第三个是j第六个是t的8个字母组成的单词"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['abjectedness',\n",
       " 'abjection',\n",
       " 'abjective',\n",
       " 'abjectly',\n",
       " 'abjectness',\n",
       " 'adjection',\n",
       " 'adjectional',\n",
       " 'adjectival',\n",
       " 'adjectivally',\n",
       " 'adjective',\n",
       " 'adjectively',\n",
       " 'adjectivism',\n",
       " 'adjectivitis',\n",
       " 'adjustable',\n",
       " 'adjustably',\n",
       " 'adjustage',\n",
       " 'adjustation',\n",
       " 'adjuster',\n",
       " 'adjustive',\n",
       " 'adjustment',\n",
       " 'antejentacular',\n",
       " 'antiprojectivity',\n",
       " 'bijouterie',\n",
       " 'coadjustment',\n",
       " 'cojusticiar',\n",
       " 'conjective',\n",
       " 'conjecturable',\n",
       " 'conjecturably',\n",
       " 'conjectural',\n",
       " 'conjecturalist',\n",
       " 'conjecturality',\n",
       " 'conjecturally',\n",
       " 'conjecture',\n",
       " 'conjecturer',\n",
       " 'coprojector',\n",
       " 'counterobjection',\n",
       " 'dejected',\n",
       " 'dejectedly',\n",
       " 'dejectedness',\n",
       " 'dejectile',\n",
       " 'dejection',\n",
       " 'dejectly',\n",
       " 'dejectory',\n",
       " 'dejecture',\n",
       " 'disjection',\n",
       " 'guanajuatite',\n",
       " 'inadjustability',\n",
       " 'inadjustable',\n",
       " 'injectable',\n",
       " 'injection',\n",
       " 'injector',\n",
       " 'injustice',\n",
       " 'insubjection',\n",
       " 'interjection',\n",
       " 'interjectional',\n",
       " 'interjectionalize',\n",
       " 'interjectionally',\n",
       " 'interjectionary',\n",
       " 'interjectionize',\n",
       " 'interjectiveness',\n",
       " 'interjector',\n",
       " 'interjectorily',\n",
       " 'interjectory',\n",
       " 'interjectural',\n",
       " 'interobjective',\n",
       " 'intersubjective',\n",
       " 'introjection',\n",
       " 'introjective',\n",
       " 'majestic',\n",
       " 'majestical',\n",
       " 'majestically',\n",
       " 'majesticalness',\n",
       " 'majesticness',\n",
       " 'majestious',\n",
       " 'majestyship',\n",
       " 'maladjusted',\n",
       " 'maladjustive',\n",
       " 'maladjustment',\n",
       " 'microinjection',\n",
       " 'microprojector',\n",
       " 'misconjecture',\n",
       " 'munjistin',\n",
       " 'nonadjectival',\n",
       " 'nonadjustable',\n",
       " 'nonadjustive',\n",
       " 'nonadjustment',\n",
       " 'nonconjectural',\n",
       " 'nonejection',\n",
       " 'nonobjection',\n",
       " 'nonobjective',\n",
       " 'nonprojection',\n",
       " 'nonprojective',\n",
       " 'nonprojectively',\n",
       " 'nonrejection',\n",
       " 'nonsubjective',\n",
       " 'objectable',\n",
       " 'objectation',\n",
       " 'objectative',\n",
       " 'objectee',\n",
       " 'objecthood',\n",
       " 'objectification',\n",
       " 'objectify',\n",
       " 'objection',\n",
       " 'objectionability',\n",
       " 'objectionable',\n",
       " 'objectionableness',\n",
       " 'objectionably',\n",
       " 'objectional',\n",
       " 'objectioner',\n",
       " 'objectionist',\n",
       " 'objectival',\n",
       " 'objectivate',\n",
       " 'objectivation',\n",
       " 'objective',\n",
       " 'objectively',\n",
       " 'objectiveness',\n",
       " 'objectivism',\n",
       " 'objectivist',\n",
       " 'objectivistic',\n",
       " 'objectivity',\n",
       " 'objectivize',\n",
       " 'objectization',\n",
       " 'objectize',\n",
       " 'objectless',\n",
       " 'objectlessly',\n",
       " 'objectlessness',\n",
       " 'objector',\n",
       " 'outjetting',\n",
       " 'overjutting',\n",
       " 'overobjectify',\n",
       " 'preadjectival',\n",
       " 'preadjective',\n",
       " 'preadjustable',\n",
       " 'preadjustment',\n",
       " 'preconjecture',\n",
       " 'prejustification',\n",
       " 'prejustify',\n",
       " 'preobjection',\n",
       " 'preobjective',\n",
       " 'prerejection',\n",
       " 'presubjection',\n",
       " 'projectable',\n",
       " 'projectedly',\n",
       " 'projectile',\n",
       " 'projecting',\n",
       " 'projectingly',\n",
       " 'projection',\n",
       " 'projectional',\n",
       " 'projectionist',\n",
       " 'projective',\n",
       " 'projectively',\n",
       " 'projectivity',\n",
       " 'projector',\n",
       " 'projectress',\n",
       " 'projectrix',\n",
       " 'projecture',\n",
       " 'readjustable',\n",
       " 'readjuster',\n",
       " 'readjustment',\n",
       " 'rejectable',\n",
       " 'rejectableness',\n",
       " 'rejectage',\n",
       " 'rejectamenta',\n",
       " 'rejecter',\n",
       " 'rejectingly',\n",
       " 'rejection',\n",
       " 'rejective',\n",
       " 'rejectment',\n",
       " 'rejector',\n",
       " 'rejustification',\n",
       " 'rejustify',\n",
       " 'reobjectivization',\n",
       " 'reobjectivize',\n",
       " 'resubjection',\n",
       " 'retrojection',\n",
       " 'semiadjectively',\n",
       " 'subjectability',\n",
       " 'subjectable',\n",
       " 'subjectdom',\n",
       " 'subjected',\n",
       " 'subjectedly',\n",
       " 'subjectedness',\n",
       " 'subjecthood',\n",
       " 'subjectibility',\n",
       " 'subjectible',\n",
       " 'subjectification',\n",
       " 'subjectify',\n",
       " 'subjectile',\n",
       " 'subjection',\n",
       " 'subjectional',\n",
       " 'subjectist',\n",
       " 'subjective',\n",
       " 'subjectively',\n",
       " 'subjectiveness',\n",
       " 'subjectivism',\n",
       " 'subjectivist',\n",
       " 'subjectivistic',\n",
       " 'subjectivistically',\n",
       " 'subjectivity',\n",
       " 'subjectivize',\n",
       " 'subjectivoidealistic',\n",
       " 'subjectless',\n",
       " 'subjectlike',\n",
       " 'subjectness',\n",
       " 'subjectship',\n",
       " 'superdejection',\n",
       " 'superinjustice',\n",
       " 'superjustification',\n",
       " 'superobjection',\n",
       " 'superobjectionable',\n",
       " 'teleobjective',\n",
       " 'trajectile',\n",
       " 'trajection',\n",
       " 'trajectitious',\n",
       " 'trajectory',\n",
       " 'transsubjective',\n",
       " 'unadjectived',\n",
       " 'unadjustably',\n",
       " 'unadjusted',\n",
       " 'unadjustment',\n",
       " 'unconjecturable',\n",
       " 'unconjectured',\n",
       " 'undejected',\n",
       " 'underadjustment',\n",
       " 'unejected',\n",
       " 'uninjectable',\n",
       " 'uninjected',\n",
       " 'uninterjected',\n",
       " 'unjesting',\n",
       " 'unjilted',\n",
       " 'unjolted',\n",
       " 'unjostled',\n",
       " 'unjustice',\n",
       " 'unjusticiable',\n",
       " 'unjustifiable',\n",
       " 'unjustifiableness',\n",
       " 'unjustifiably',\n",
       " 'unjustified',\n",
       " 'unjustifiedly',\n",
       " 'unjustifiedness',\n",
       " 'unjustify',\n",
       " 'unjustled',\n",
       " 'unjustly',\n",
       " 'unjustness',\n",
       " 'unmajestic',\n",
       " 'unobjected',\n",
       " 'unobjectionable',\n",
       " 'unobjectionableness',\n",
       " 'unobjectionably',\n",
       " 'unobjectional',\n",
       " 'unobjective',\n",
       " 'unprojected',\n",
       " 'unprojecting',\n",
       " 'unrejectable',\n",
       " 'unsubjectable',\n",
       " 'unsubjected',\n",
       " 'unsubjectedness',\n",
       " 'unsubjection',\n",
       " 'unsubjective',\n",
       " 'unsubjectlike']"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[w for w in wordlist if re.search(\"..j..t..\", w)] # 如果不限制 ^ 匹配字符的开始 $ 匹配字符的结尾，那么会有很多超过8字符的被匹配到"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum(1 for w in wordlist if re.search(\"^e-?mail$\", w)) # ? 匹配前边的字符0次或1次         # 这行代码的意思是统计总共由多少email或e-mail "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2、范围与闭包"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "![3.2](./picture/3.2.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['gold', 'golf', 'hold', 'hole']"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 通过序列4653输入。有哪些其它词汇由相同的序列产生？\n",
    "[w for w in wordlist if re.search(\"^[ghi][mno][jkl][def]$\", w)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['g',\n",
       " 'ghoom',\n",
       " 'gig',\n",
       " 'giggling',\n",
       " 'gigolo',\n",
       " 'gilim',\n",
       " 'gill',\n",
       " 'gilling',\n",
       " 'gilo',\n",
       " 'gim',\n",
       " 'gin',\n",
       " 'ging',\n",
       " 'gingili',\n",
       " 'gink',\n",
       " 'ginkgo',\n",
       " 'ginning',\n",
       " 'gio',\n",
       " 'glink',\n",
       " 'glom',\n",
       " 'glonoin',\n",
       " 'gloom',\n",
       " 'glooming',\n",
       " 'gnomon',\n",
       " 'go',\n",
       " 'gog',\n",
       " 'gogo',\n",
       " 'goi',\n",
       " 'going',\n",
       " 'gol',\n",
       " 'goli',\n",
       " 'gon',\n",
       " 'gong',\n",
       " 'gonion',\n",
       " 'goo',\n",
       " 'googol',\n",
       " 'gook',\n",
       " 'gool',\n",
       " 'goon',\n",
       " 'h',\n",
       " 'hi',\n",
       " 'high',\n",
       " 'hill',\n",
       " 'him',\n",
       " 'hin',\n",
       " 'hing',\n",
       " 'hinoki',\n",
       " 'ho',\n",
       " 'hog',\n",
       " 'hoggin',\n",
       " 'hogling',\n",
       " 'hoi',\n",
       " 'hoin',\n",
       " 'holing',\n",
       " 'holl',\n",
       " 'hollin',\n",
       " 'hollo',\n",
       " 'hollong',\n",
       " 'holm',\n",
       " 'homo',\n",
       " 'homologon',\n",
       " 'hong',\n",
       " 'honk',\n",
       " 'hook',\n",
       " 'hoon',\n",
       " 'i',\n",
       " 'igloo',\n",
       " 'ihi',\n",
       " 'ilk',\n",
       " 'ill',\n",
       " 'imi',\n",
       " 'imino',\n",
       " 'immi',\n",
       " 'in',\n",
       " 'ing',\n",
       " 'ingoing',\n",
       " 'inion',\n",
       " 'ink',\n",
       " 'inkling',\n",
       " 'inlook',\n",
       " 'inn',\n",
       " 'inning',\n",
       " 'io',\n",
       " 'ion',\n",
       " 'j',\n",
       " 'jhool',\n",
       " 'jig',\n",
       " 'jing',\n",
       " 'jingling',\n",
       " 'jingo',\n",
       " 'jinjili',\n",
       " 'jink',\n",
       " 'jinn',\n",
       " 'jinni',\n",
       " 'jo',\n",
       " 'jog',\n",
       " 'johnin',\n",
       " 'join',\n",
       " 'joining',\n",
       " 'joll',\n",
       " 'joom',\n",
       " 'k',\n",
       " 'kiki',\n",
       " 'kil',\n",
       " 'kilhig',\n",
       " 'kilim',\n",
       " 'kill',\n",
       " 'killing',\n",
       " 'kiln',\n",
       " 'kilo',\n",
       " 'kim',\n",
       " 'kimono',\n",
       " 'kin',\n",
       " 'king',\n",
       " 'kingling',\n",
       " 'kink',\n",
       " 'kino',\n",
       " 'klom',\n",
       " 'knoll',\n",
       " 'ko',\n",
       " 'kohl',\n",
       " 'koi',\n",
       " 'koil',\n",
       " 'koilon',\n",
       " 'koinon',\n",
       " 'kokil',\n",
       " 'kokio',\n",
       " 'koko',\n",
       " 'kokoon',\n",
       " 'kolo',\n",
       " 'kolokolo',\n",
       " 'kon',\n",
       " 'kongoni',\n",
       " 'konini',\n",
       " 'l',\n",
       " 'li',\n",
       " 'lignin',\n",
       " 'liin',\n",
       " 'likin',\n",
       " 'liking',\n",
       " 'liknon',\n",
       " 'lill',\n",
       " 'lim',\n",
       " 'liming',\n",
       " 'limn',\n",
       " 'limonin',\n",
       " 'lin',\n",
       " 'ling',\n",
       " 'lingo',\n",
       " 'linin',\n",
       " 'lining',\n",
       " 'link',\n",
       " 'linking',\n",
       " 'linn',\n",
       " 'lino',\n",
       " 'linolin',\n",
       " 'linon',\n",
       " 'lion',\n",
       " 'lo',\n",
       " 'log',\n",
       " 'loggin',\n",
       " 'logging',\n",
       " 'login',\n",
       " 'logion',\n",
       " 'logoi',\n",
       " 'loin',\n",
       " 'loll',\n",
       " 'long',\n",
       " 'longing',\n",
       " 'loo',\n",
       " 'look',\n",
       " 'looking',\n",
       " 'loom',\n",
       " 'looming',\n",
       " 'loon',\n",
       " 'm',\n",
       " 'mho',\n",
       " 'mi',\n",
       " 'mig',\n",
       " 'miglio',\n",
       " 'mignon',\n",
       " 'mijl',\n",
       " 'mil',\n",
       " 'milk',\n",
       " 'milking',\n",
       " 'mill',\n",
       " 'milling',\n",
       " 'million',\n",
       " 'milo',\n",
       " 'mim',\n",
       " 'min',\n",
       " 'ming',\n",
       " 'minikin',\n",
       " 'minim',\n",
       " 'mining',\n",
       " 'minion',\n",
       " 'mink',\n",
       " 'minning',\n",
       " 'mino',\n",
       " 'mo',\n",
       " 'mog',\n",
       " 'mogo',\n",
       " 'moho',\n",
       " 'moil',\n",
       " 'moiling',\n",
       " 'moio',\n",
       " 'mojo',\n",
       " 'moki',\n",
       " 'moko',\n",
       " 'momo',\n",
       " 'mon',\n",
       " 'mong',\n",
       " 'monk',\n",
       " 'mono',\n",
       " 'moo',\n",
       " 'mooing',\n",
       " 'mool',\n",
       " 'moon',\n",
       " 'mooning',\n",
       " 'n',\n",
       " 'ni',\n",
       " 'nig',\n",
       " 'niggling',\n",
       " 'nigh',\n",
       " 'nil',\n",
       " 'nim',\n",
       " 'ninon',\n",
       " 'niog',\n",
       " 'no',\n",
       " 'nog',\n",
       " 'noggin',\n",
       " 'nogging',\n",
       " 'noil',\n",
       " 'noll',\n",
       " 'nolo',\n",
       " 'non',\n",
       " 'nonillion',\n",
       " 'nonion',\n",
       " 'nook',\n",
       " 'nooking',\n",
       " 'noon',\n",
       " 'nooning',\n",
       " 'o',\n",
       " 'oh',\n",
       " 'ohm',\n",
       " 'oho',\n",
       " 'oii',\n",
       " 'oil',\n",
       " 'oki',\n",
       " 'olio',\n",
       " 'olm',\n",
       " 'om',\n",
       " 'on',\n",
       " 'ongoing',\n",
       " 'onion',\n",
       " 'onlook',\n",
       " 'onlooking',\n",
       " 'oolong']"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 匹配只使用中间行的4、5、6 键的词汇\n",
    "[w for w in wordlist if re.search(\"^[g-o]+$\", w)]   # - 表示范围 + 表示匹配1次或多次"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['miiiiiiiiiiiiinnnnnnnnnnneeeeeeeeee',\n",
       " 'miiiiiinnnnnnnnnneeeeeeee',\n",
       " 'mine',\n",
       " 'mmmmmmmmiiiiiiiiinnnnnnnnneeeeeeee']"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "chat_words = sorted(set(w for w in nltk.corpus.nps_chat.words()))\n",
    "[w for w in chat_words if re.search(\"^m+i+n+e+$\", w)]  # + 表示匹配1次或多次"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['',\n",
       " 'e',\n",
       " 'i',\n",
       " 'in',\n",
       " 'm',\n",
       " 'me',\n",
       " 'meeeeeeeeeeeee',\n",
       " 'mi',\n",
       " 'miiiiiiiiiiiiinnnnnnnnnnneeeeeeeeee',\n",
       " 'miiiiiinnnnnnnnnneeeeeeee',\n",
       " 'min',\n",
       " 'mine',\n",
       " 'mm',\n",
       " 'mmm',\n",
       " 'mmmm',\n",
       " 'mmmmm',\n",
       " 'mmmmmm',\n",
       " 'mmmmmmmmiiiiiiiiinnnnnnnnneeeeeeee',\n",
       " 'mmmmmmmmmm',\n",
       " 'mmmmmmmmmmmmm',\n",
       " 'mmmmmmmmmmmmmm',\n",
       " 'n',\n",
       " 'ne']"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[w for w in chat_words if re.search(\"^m*i*n*e*$\", w)]   # * 表示匹配0次或多次"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['a',\n",
       " 'aaaaaaaaaaaaaaaaa',\n",
       " 'aaahhhh',\n",
       " 'ah',\n",
       " 'ahah',\n",
       " 'ahahah',\n",
       " 'ahh',\n",
       " 'ahhahahaha',\n",
       " 'ahhh',\n",
       " 'ahhhh',\n",
       " 'ahhhhhh',\n",
       " 'ahhhhhhhhhhhhhh',\n",
       " 'h',\n",
       " 'ha',\n",
       " 'haaa',\n",
       " 'hah',\n",
       " 'haha',\n",
       " 'hahaaa',\n",
       " 'hahah',\n",
       " 'hahaha',\n",
       " 'hahahaa',\n",
       " 'hahahah',\n",
       " 'hahahaha',\n",
       " 'hahahahaaa',\n",
       " 'hahahahahaha',\n",
       " 'hahahahahahaha',\n",
       " 'hahahahahahahahahahahahahahahaha',\n",
       " 'hahahhahah',\n",
       " 'hahhahahaha']"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[w for w in chat_words if re.search(\"^[ha]+$\", w)]  # [ ] 匹配集合里边的没有顺序"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['0.0085',\n",
       " '0.05',\n",
       " '0.1',\n",
       " '0.16',\n",
       " '0.2',\n",
       " '0.25',\n",
       " '0.28',\n",
       " '0.3',\n",
       " '0.4',\n",
       " '0.5',\n",
       " '0.50',\n",
       " '0.54',\n",
       " '0.56',\n",
       " '0.60',\n",
       " '0.7',\n",
       " '0.82',\n",
       " '0.84',\n",
       " '0.9',\n",
       " '0.95',\n",
       " '0.99',\n",
       " '1.01',\n",
       " '1.1',\n",
       " '1.125',\n",
       " '1.14',\n",
       " '1.1650',\n",
       " '1.17',\n",
       " '1.18',\n",
       " '1.19',\n",
       " '1.2',\n",
       " '1.20',\n",
       " '1.24',\n",
       " '1.25',\n",
       " '1.26',\n",
       " '1.28',\n",
       " '1.35',\n",
       " '1.39',\n",
       " '1.4',\n",
       " '1.457',\n",
       " '1.46',\n",
       " '1.49',\n",
       " '1.5',\n",
       " '1.50',\n",
       " '1.55',\n",
       " '1.56',\n",
       " '1.5755',\n",
       " '1.5805',\n",
       " '1.6',\n",
       " '1.61',\n",
       " '1.637',\n",
       " '1.64',\n",
       " '1.65',\n",
       " '1.7',\n",
       " '1.75',\n",
       " '1.76',\n",
       " '1.8',\n",
       " '1.82',\n",
       " '1.8415',\n",
       " '1.85',\n",
       " '1.8500',\n",
       " '1.9',\n",
       " '1.916',\n",
       " '1.92',\n",
       " '10.19',\n",
       " '10.2',\n",
       " '10.5',\n",
       " '107.03',\n",
       " '107.9',\n",
       " '109.73',\n",
       " '11.10',\n",
       " '11.5',\n",
       " '11.57',\n",
       " '11.6',\n",
       " '11.72',\n",
       " '11.95',\n",
       " '112.9',\n",
       " '113.2',\n",
       " '116.3',\n",
       " '116.4',\n",
       " '116.7',\n",
       " '116.9',\n",
       " '118.6',\n",
       " '12.09',\n",
       " '12.5',\n",
       " '12.52',\n",
       " '12.68',\n",
       " '12.7',\n",
       " '12.82',\n",
       " '12.97',\n",
       " '120.7',\n",
       " '1206.26',\n",
       " '121.6',\n",
       " '126.1',\n",
       " '126.15',\n",
       " '127.03',\n",
       " '129.91',\n",
       " '13.1',\n",
       " '13.15',\n",
       " '13.5',\n",
       " '13.50',\n",
       " '13.625',\n",
       " '13.65',\n",
       " '13.73',\n",
       " '13.8',\n",
       " '13.90',\n",
       " '130.6',\n",
       " '130.7',\n",
       " '131.01',\n",
       " '132.9',\n",
       " '133.7',\n",
       " '133.8',\n",
       " '14.00',\n",
       " '14.13',\n",
       " '14.26',\n",
       " '14.28',\n",
       " '14.43',\n",
       " '14.5',\n",
       " '14.53',\n",
       " '14.54',\n",
       " '14.6',\n",
       " '14.75',\n",
       " '14.99',\n",
       " '141.9',\n",
       " '142.84',\n",
       " '142.85',\n",
       " '143.08',\n",
       " '143.80',\n",
       " '143.93',\n",
       " '148.9',\n",
       " '149.9',\n",
       " '15.5',\n",
       " '150.00',\n",
       " '153.3',\n",
       " '154.2',\n",
       " '16.05',\n",
       " '16.09',\n",
       " '16.125',\n",
       " '16.2',\n",
       " '16.5',\n",
       " '16.68',\n",
       " '16.7',\n",
       " '16.9',\n",
       " '169.9',\n",
       " '17.3',\n",
       " '17.4',\n",
       " '17.5',\n",
       " '17.95',\n",
       " '1738.1',\n",
       " '176.1',\n",
       " '18.3',\n",
       " '18.6',\n",
       " '18.95',\n",
       " '185.9',\n",
       " '188.84',\n",
       " '19.3',\n",
       " '19.50',\n",
       " '19.6',\n",
       " '19.94',\n",
       " '19.95',\n",
       " '191.9',\n",
       " '2.07',\n",
       " '2.1',\n",
       " '2.15',\n",
       " '2.19',\n",
       " '2.2',\n",
       " '2.25',\n",
       " '2.29',\n",
       " '2.3',\n",
       " '2.30',\n",
       " '2.35',\n",
       " '2.375',\n",
       " '2.4',\n",
       " '2.42',\n",
       " '2.44',\n",
       " '2.46',\n",
       " '2.47',\n",
       " '2.5',\n",
       " '2.50',\n",
       " '2.6',\n",
       " '2.62',\n",
       " '2.65',\n",
       " '2.7',\n",
       " '2.75',\n",
       " '2.8',\n",
       " '2.80',\n",
       " '2.87',\n",
       " '2.875',\n",
       " '2.9',\n",
       " '2.95',\n",
       " '20.07',\n",
       " '20.5',\n",
       " '21.1',\n",
       " '21.9',\n",
       " '2141.7',\n",
       " '2160.1',\n",
       " '2163.2',\n",
       " '22.75',\n",
       " '220.45',\n",
       " '221.4',\n",
       " '225.6',\n",
       " '23.25',\n",
       " '23.4',\n",
       " '23.5',\n",
       " '23.72',\n",
       " '234.4',\n",
       " '236.74',\n",
       " '236.79',\n",
       " '24.95',\n",
       " '25.50',\n",
       " '25.6',\n",
       " '251.2',\n",
       " '26.2',\n",
       " '26.5',\n",
       " '26.8',\n",
       " '263.07',\n",
       " '2645.90',\n",
       " '2691.19',\n",
       " '27.1',\n",
       " '27.4',\n",
       " '273.5',\n",
       " '278.7',\n",
       " '28.25',\n",
       " '28.36',\n",
       " '28.4',\n",
       " '28.5',\n",
       " '28.53',\n",
       " '28.6',\n",
       " '29.3',\n",
       " '29.4',\n",
       " '29.9',\n",
       " '292.32',\n",
       " '3.01',\n",
       " '3.04',\n",
       " '3.1',\n",
       " '3.16',\n",
       " '3.18',\n",
       " '3.19',\n",
       " '3.2',\n",
       " '3.20',\n",
       " '3.23',\n",
       " '3.253',\n",
       " '3.28',\n",
       " '3.3',\n",
       " '3.35',\n",
       " '3.375',\n",
       " '3.4',\n",
       " '3.42',\n",
       " '3.43',\n",
       " '3.5',\n",
       " '3.55',\n",
       " '3.6',\n",
       " '3.61',\n",
       " '3.625',\n",
       " '3.7',\n",
       " '3.75',\n",
       " '3.8',\n",
       " '3.80',\n",
       " '3.9',\n",
       " '30.6',\n",
       " '30.9',\n",
       " '319.75',\n",
       " '32.8',\n",
       " '334.5',\n",
       " '34.625',\n",
       " '341.20',\n",
       " '3436.58',\n",
       " '35.2',\n",
       " '35.7',\n",
       " '352.7',\n",
       " '352.9',\n",
       " '35500.64',\n",
       " '35564.43',\n",
       " '36.9',\n",
       " '361.8',\n",
       " '3648.82',\n",
       " '37.3',\n",
       " '37.5',\n",
       " '372.14',\n",
       " '372.9',\n",
       " '374.19',\n",
       " '374.20',\n",
       " '377.60',\n",
       " '38.3',\n",
       " '38.375',\n",
       " '38.5',\n",
       " '38.875',\n",
       " '387.8',\n",
       " '4.1',\n",
       " '4.10',\n",
       " '4.2',\n",
       " '4.25',\n",
       " '4.3',\n",
       " '4.4',\n",
       " '4.5',\n",
       " '4.55',\n",
       " '4.6',\n",
       " '4.7',\n",
       " '4.75',\n",
       " '4.8',\n",
       " '4.875',\n",
       " '4.898',\n",
       " '4.9',\n",
       " '40.21',\n",
       " '41.60',\n",
       " '415.6',\n",
       " '415.8',\n",
       " '42.1',\n",
       " '42.5',\n",
       " '422.5',\n",
       " '43.875',\n",
       " '434.4',\n",
       " '436.01',\n",
       " '446.62',\n",
       " '449.04',\n",
       " '45.2',\n",
       " '45.3',\n",
       " '45.75',\n",
       " '456.64',\n",
       " '46.1',\n",
       " '47.1',\n",
       " '47.125',\n",
       " '47.5',\n",
       " '47.6',\n",
       " '49.9',\n",
       " '494.50',\n",
       " '497.34',\n",
       " '5.1',\n",
       " '5.2180',\n",
       " '5.276',\n",
       " '5.29',\n",
       " '5.3',\n",
       " '5.39',\n",
       " '5.4',\n",
       " '5.435',\n",
       " '5.5',\n",
       " '5.57',\n",
       " '5.6',\n",
       " '5.63',\n",
       " '5.7',\n",
       " '5.70',\n",
       " '5.8',\n",
       " '5.82',\n",
       " '5.9',\n",
       " '5.92',\n",
       " '50.1',\n",
       " '50.38',\n",
       " '50.45',\n",
       " '51.25',\n",
       " '51.6',\n",
       " '55.1',\n",
       " '566.54',\n",
       " '57.50',\n",
       " '57.6',\n",
       " '57.7',\n",
       " '58.64',\n",
       " '59.6',\n",
       " '59.9',\n",
       " '6.03',\n",
       " '6.1',\n",
       " '6.20',\n",
       " '6.21',\n",
       " '6.25',\n",
       " '6.4',\n",
       " '6.40',\n",
       " '6.44',\n",
       " '6.5',\n",
       " '6.50',\n",
       " '6.53',\n",
       " '6.6',\n",
       " '6.7',\n",
       " '6.70',\n",
       " '6.79',\n",
       " '6.84',\n",
       " '6.9',\n",
       " '60.36',\n",
       " '618.1',\n",
       " '62.1',\n",
       " '62.5',\n",
       " '62.625',\n",
       " '63.79',\n",
       " '630.9',\n",
       " '64.5',\n",
       " '66.5',\n",
       " '7.15',\n",
       " '7.2',\n",
       " '7.20',\n",
       " '7.272',\n",
       " '7.3',\n",
       " '7.4',\n",
       " '7.40',\n",
       " '7.422',\n",
       " '7.45',\n",
       " '7.458',\n",
       " '7.5',\n",
       " '7.50',\n",
       " '7.52',\n",
       " '7.55',\n",
       " '7.60',\n",
       " '7.62',\n",
       " '7.63',\n",
       " '7.65',\n",
       " '7.74',\n",
       " '7.78',\n",
       " '7.79',\n",
       " '7.8',\n",
       " '7.80',\n",
       " '7.84',\n",
       " '7.88',\n",
       " '7.90',\n",
       " '7.95',\n",
       " '70.2',\n",
       " '70.7',\n",
       " '705.6',\n",
       " '72.7',\n",
       " '734.9',\n",
       " '737.5',\n",
       " '77.56',\n",
       " '77.6',\n",
       " '77.70',\n",
       " '8.04',\n",
       " '8.06',\n",
       " '8.07',\n",
       " '8.1',\n",
       " '8.12',\n",
       " '8.14',\n",
       " '8.15',\n",
       " '8.19',\n",
       " '8.2',\n",
       " '8.22',\n",
       " '8.25',\n",
       " '8.30',\n",
       " '8.35',\n",
       " '8.45',\n",
       " '8.467',\n",
       " '8.47',\n",
       " '8.48',\n",
       " '8.5',\n",
       " '8.50',\n",
       " '8.53',\n",
       " '8.55',\n",
       " '8.56',\n",
       " '8.575',\n",
       " '8.60',\n",
       " '8.64',\n",
       " '8.65',\n",
       " '8.70',\n",
       " '8.75',\n",
       " '8.9',\n",
       " '80.50',\n",
       " '80.8',\n",
       " '81.8',\n",
       " '811.9',\n",
       " '83.4',\n",
       " '84.29',\n",
       " '84.9',\n",
       " '85.1',\n",
       " '85.7',\n",
       " '86.12',\n",
       " '87.5',\n",
       " '88.32',\n",
       " '89.7',\n",
       " '89.9',\n",
       " '9.3',\n",
       " '9.32',\n",
       " '9.37',\n",
       " '9.45',\n",
       " '9.5',\n",
       " '9.625',\n",
       " '9.75',\n",
       " '9.8',\n",
       " '9.82',\n",
       " '9.9',\n",
       " '92.9',\n",
       " '93.3',\n",
       " '93.9',\n",
       " '94.2',\n",
       " '94.8',\n",
       " '95.09',\n",
       " '96.4',\n",
       " '98.3',\n",
       " '99.1',\n",
       " '99.3']"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wsj = sorted(set(nltk.corpus.treebank.words()))\n",
    "[w for w in wsj if re.search(\"^[0-9]+\\.[0-9]+$\", w)] # \\. 表示后边的字符.不在具有转义含义而是字面的表示 . "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['C$', 'US$']"
      ]
     },
     "execution_count": 113,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[w for w in wsj if re.search(\"^[A-Z]+\\$$\", w)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['1614',\n",
       " '1637',\n",
       " '1787',\n",
       " '1901',\n",
       " '1903',\n",
       " '1917',\n",
       " '1925',\n",
       " '1929',\n",
       " '1933',\n",
       " '1934',\n",
       " '1948',\n",
       " '1953',\n",
       " '1955',\n",
       " '1956',\n",
       " '1961',\n",
       " '1965',\n",
       " '1966',\n",
       " '1967',\n",
       " '1968',\n",
       " '1969',\n",
       " '1970',\n",
       " '1971',\n",
       " '1972',\n",
       " '1973',\n",
       " '1975',\n",
       " '1976',\n",
       " '1977',\n",
       " '1979',\n",
       " '1980',\n",
       " '1981',\n",
       " '1982',\n",
       " '1983',\n",
       " '1984',\n",
       " '1985',\n",
       " '1986',\n",
       " '1987',\n",
       " '1988',\n",
       " '1989',\n",
       " '1990',\n",
       " '1991',\n",
       " '1992',\n",
       " '1993',\n",
       " '1994',\n",
       " '1995',\n",
       " '1996',\n",
       " '1997',\n",
       " '1998',\n",
       " '1999',\n",
       " '2000',\n",
       " '2005',\n",
       " '2009',\n",
       " '2017',\n",
       " '2019',\n",
       " '2029',\n",
       " '3057',\n",
       " '8300']"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[w for w in wsj if re.search(\"^[0-9]{4}$\", w)] # {4} 表示匹配前边的 字符或集合 四次"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['10-day',\n",
       " '10-lap',\n",
       " '10-year',\n",
       " '100-share',\n",
       " '12-point',\n",
       " '12-year',\n",
       " '14-hour',\n",
       " '15-day',\n",
       " '150-point',\n",
       " '190-point',\n",
       " '20-point',\n",
       " '20-stock',\n",
       " '21-month',\n",
       " '237-seat',\n",
       " '240-page',\n",
       " '27-year',\n",
       " '30-day',\n",
       " '30-point',\n",
       " '30-share',\n",
       " '30-year',\n",
       " '300-day',\n",
       " '36-day',\n",
       " '36-store',\n",
       " '42-year',\n",
       " '50-state',\n",
       " '500-stock',\n",
       " '52-week',\n",
       " '69-point',\n",
       " '84-month',\n",
       " '87-store',\n",
       " '90-day']"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[w for w in wsj if re.search(\"^[0-9]+-[a-z]{3,5}$\", w)] # 中间的 - 表示字符本身， {3,5} 表示匹配前边的字符或组合3次或5次"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['black-and-white',\n",
       " 'bread-and-butter',\n",
       " 'father-in-law',\n",
       " 'machine-gun-toting',\n",
       " 'savings-and-loan']"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[w for w in wsj if re.search(\"^[a-z]{5,}-[a-z]{2,3}-[a-z]{,6}$\", w)]  # {5,} 表示匹配前边的字符或组合5次或5次以上 {,6} 表示匹配前边的字符或组合6次或6次以下"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['62%-owned',\n",
       " 'Absorbed',\n",
       " 'According',\n",
       " 'Adopting',\n",
       " 'Advanced',\n",
       " 'Advancing',\n",
       " 'Alfred',\n",
       " 'Allied',\n",
       " 'Annualized',\n",
       " 'Anything',\n",
       " 'Arbitrage-related',\n",
       " 'Arbitraging',\n",
       " 'Asked',\n",
       " 'Assuming',\n",
       " 'Atlanta-based',\n",
       " 'Baking',\n",
       " 'Banking',\n",
       " 'Beginning',\n",
       " 'Beijing',\n",
       " 'Being',\n",
       " 'Bermuda-based',\n",
       " 'Betting',\n",
       " 'Boeing',\n",
       " 'Broadcasting',\n",
       " 'Bucking',\n",
       " 'Buying',\n",
       " 'Calif.-based',\n",
       " 'Change-ringing',\n",
       " 'Citing',\n",
       " 'Concerned',\n",
       " 'Confronted',\n",
       " 'Conn.based',\n",
       " 'Consolidated',\n",
       " 'Continued',\n",
       " 'Continuing',\n",
       " 'Declining',\n",
       " 'Defending',\n",
       " 'Depending',\n",
       " 'Designated',\n",
       " 'Determining',\n",
       " 'Developed',\n",
       " 'Died',\n",
       " 'During',\n",
       " 'Encouraged',\n",
       " 'Encouraging',\n",
       " 'English-speaking',\n",
       " 'Estimated',\n",
       " 'Everything',\n",
       " 'Excluding',\n",
       " 'Exxon-owned',\n",
       " 'Faulding',\n",
       " 'Fed',\n",
       " 'Feeding',\n",
       " 'Filling',\n",
       " 'Filmed',\n",
       " 'Financing',\n",
       " 'Following',\n",
       " 'Founded',\n",
       " 'Fracturing',\n",
       " 'Francisco-based',\n",
       " 'Fred',\n",
       " 'Funded',\n",
       " 'Funding',\n",
       " 'Generalized',\n",
       " 'Germany-based',\n",
       " 'Getting',\n",
       " 'Guaranteed',\n",
       " 'Having',\n",
       " 'Heating',\n",
       " 'Heightened',\n",
       " 'Holding',\n",
       " 'Housing',\n",
       " 'Illuminating',\n",
       " 'Indeed',\n",
       " 'Indexing',\n",
       " 'Irving',\n",
       " 'Jersey-based',\n",
       " 'Judging',\n",
       " 'Knowing',\n",
       " 'Learning',\n",
       " 'Legislating',\n",
       " 'Leming',\n",
       " 'Limited',\n",
       " 'London-based',\n",
       " 'Manfred',\n",
       " 'Manufacturing',\n",
       " 'Melamed',\n",
       " 'Miami-based',\n",
       " 'Mich.-based',\n",
       " 'Mining',\n",
       " 'Minneapolis-based',\n",
       " 'Mo.-based',\n",
       " 'Mortgage-Backed',\n",
       " 'Moving',\n",
       " 'Muzzling',\n",
       " 'N.J.-based',\n",
       " 'NBC-owned',\n",
       " 'NIH-appointed',\n",
       " 'Named',\n",
       " 'No-Smoking',\n",
       " 'Observing',\n",
       " 'Offering',\n",
       " 'Ohio-based',\n",
       " 'Orleans-based',\n",
       " 'Packaging',\n",
       " 'Performing',\n",
       " 'Philadelphia-based',\n",
       " 'Posted',\n",
       " 'Provided',\n",
       " 'Publishing',\n",
       " 'Purchasing',\n",
       " 'Rated',\n",
       " 'Reached',\n",
       " 'Red',\n",
       " 'Red-blooded',\n",
       " 'Reducing',\n",
       " 'Reed',\n",
       " 'Regarded',\n",
       " 'Rekindled',\n",
       " 'Related',\n",
       " 'Ringing',\n",
       " 'Rolling',\n",
       " 'Sacramento-based',\n",
       " 'Scoring',\n",
       " 'Seattle-based',\n",
       " 'Seed',\n",
       " 'Skilled',\n",
       " 'Smelting',\n",
       " 'Something',\n",
       " 'Spending',\n",
       " 'Standardized',\n",
       " 'Standing',\n",
       " 'Starting',\n",
       " 'Sterling',\n",
       " 'Taking',\n",
       " 'Texas-based',\n",
       " 'Toronto-based',\n",
       " 'Traded',\n",
       " 'Trading',\n",
       " 'Troubled',\n",
       " 'U.N.-supervised',\n",
       " 'U.S.-backed',\n",
       " 'United',\n",
       " 'Used',\n",
       " 'Varying',\n",
       " 'Washington-based',\n",
       " 'Whiting',\n",
       " 'Wilfred',\n",
       " 'Winning',\n",
       " 'Xiaoping',\n",
       " 'York-based',\n",
       " 'Zayed',\n",
       " 'abandoned',\n",
       " 'abating',\n",
       " 'abolishing',\n",
       " 'abortion-related',\n",
       " 'abounding',\n",
       " 'abridging',\n",
       " 'absorbed',\n",
       " 'acceded',\n",
       " 'accelerated',\n",
       " 'accepted',\n",
       " 'accepting',\n",
       " 'according',\n",
       " 'accounted',\n",
       " 'accounting',\n",
       " 'accrued',\n",
       " 'accumulated',\n",
       " 'accused',\n",
       " 'accusing',\n",
       " 'achieved',\n",
       " 'achieving',\n",
       " 'acknowledging',\n",
       " 'acquired',\n",
       " 'acquiring',\n",
       " 'acquisition-minded',\n",
       " 'acted',\n",
       " 'acting',\n",
       " 'adapted',\n",
       " 'adapting',\n",
       " 'added',\n",
       " 'adding',\n",
       " 'addressing',\n",
       " 'adjusted',\n",
       " 'adjusting',\n",
       " 'admitted',\n",
       " 'admitting',\n",
       " 'adopted',\n",
       " 'advanced',\n",
       " 'advancing',\n",
       " 'advertised',\n",
       " 'advertising',\n",
       " 'advised',\n",
       " 'advocated',\n",
       " 'advocating',\n",
       " 'affecting',\n",
       " 'afflicted',\n",
       " 'aggravated',\n",
       " 'agreed',\n",
       " 'agreeing',\n",
       " 'ailing',\n",
       " 'aimed',\n",
       " 'aiming',\n",
       " 'aired',\n",
       " 'airline-related',\n",
       " 'alarmed',\n",
       " 'alienated',\n",
       " 'alleged',\n",
       " 'alleging',\n",
       " 'allocated',\n",
       " 'allowed',\n",
       " 'altered',\n",
       " 'altering',\n",
       " 'amended',\n",
       " 'amending',\n",
       " 'amounted',\n",
       " 'amusing',\n",
       " 'angered',\n",
       " 'announced',\n",
       " 'annoyed',\n",
       " 'annualized',\n",
       " 'answered',\n",
       " 'anti-dumping',\n",
       " 'anticipated',\n",
       " 'anticipating',\n",
       " 'anything',\n",
       " 'apologizing',\n",
       " 'appealing',\n",
       " 'appeared',\n",
       " 'appearing',\n",
       " 'applied',\n",
       " 'appointed',\n",
       " 'approached',\n",
       " 'appropriated',\n",
       " 'approved',\n",
       " 'arched',\n",
       " 'argued',\n",
       " 'arguing',\n",
       " 'arising',\n",
       " 'armed',\n",
       " 'arranged',\n",
       " 'arrested',\n",
       " 'arrived',\n",
       " 'asbestos-related',\n",
       " 'asked',\n",
       " 'asking',\n",
       " 'assassinated',\n",
       " 'assembled',\n",
       " 'asserted',\n",
       " 'asserting',\n",
       " 'assessed',\n",
       " 'assigned',\n",
       " 'assisted',\n",
       " 'associated',\n",
       " 'assumed',\n",
       " 'assuming',\n",
       " 'assured',\n",
       " 'attached',\n",
       " 'attacking',\n",
       " 'attempted',\n",
       " 'attempting',\n",
       " 'attended',\n",
       " 'attending',\n",
       " 'attracted',\n",
       " 'attracting',\n",
       " 'attributed',\n",
       " 'auctioned',\n",
       " 'authorized',\n",
       " 'authorizing',\n",
       " 'automated',\n",
       " 'automotive-lighting',\n",
       " 'averaged',\n",
       " 'averted',\n",
       " 'avoiding',\n",
       " 'awarded',\n",
       " 'awarding',\n",
       " 'backed',\n",
       " 'backing',\n",
       " 'balanced',\n",
       " 'bald-faced',\n",
       " 'balkanized',\n",
       " 'balked',\n",
       " 'balloting',\n",
       " 'bank-backed',\n",
       " 'banking',\n",
       " 'banned',\n",
       " 'banning',\n",
       " 'barking',\n",
       " 'barred',\n",
       " 'based',\n",
       " 'battered',\n",
       " 'battery-operated',\n",
       " 'batting',\n",
       " 'bearing',\n",
       " 'becoming',\n",
       " 'bedding',\n",
       " 'befuddled',\n",
       " 'beginning',\n",
       " 'behaving',\n",
       " 'beheading',\n",
       " 'being',\n",
       " 'beleaguered',\n",
       " 'believed',\n",
       " 'bell-ringing',\n",
       " 'belonging',\n",
       " 'benefited',\n",
       " 'best-selling',\n",
       " 'betting',\n",
       " 'bickering',\n",
       " 'bidding',\n",
       " 'billed',\n",
       " 'billing',\n",
       " 'blamed',\n",
       " 'bled',\n",
       " 'blessing',\n",
       " 'blighted',\n",
       " 'blocked',\n",
       " 'blurred',\n",
       " 'boarding',\n",
       " 'bolstered',\n",
       " 'bombarding',\n",
       " 'booked',\n",
       " 'booming',\n",
       " 'boosted',\n",
       " 'boosting',\n",
       " 'borrowed',\n",
       " 'borrowing',\n",
       " 'botched',\n",
       " 'bothered',\n",
       " 'bounced',\n",
       " 'bowed',\n",
       " 'breaking',\n",
       " 'breathed',\n",
       " 'breathtaking',\n",
       " 'breed',\n",
       " 'bribed',\n",
       " 'bribing',\n",
       " 'briefing',\n",
       " 'brightened',\n",
       " 'bring',\n",
       " 'bringing',\n",
       " 'broad-based',\n",
       " 'broadcasting',\n",
       " 'broadened',\n",
       " 'brokering',\n",
       " 'brushed',\n",
       " 'budding',\n",
       " 'building',\n",
       " 'bundling',\n",
       " 'buoyed',\n",
       " 'burned',\n",
       " 'buying',\n",
       " 'calculated',\n",
       " 'called',\n",
       " 'calling',\n",
       " 'campaigning',\n",
       " 'cancer-causing',\n",
       " 'capitalized',\n",
       " 'capped',\n",
       " 'captivating',\n",
       " 'cared',\n",
       " 'carried',\n",
       " 'carrying',\n",
       " 'cascading',\n",
       " 'casting',\n",
       " 'caused',\n",
       " 'causing',\n",
       " 'cautioned',\n",
       " 'ceiling',\n",
       " 'centralized',\n",
       " 'certified',\n",
       " 'chaired',\n",
       " 'challenging',\n",
       " 'championing',\n",
       " 'change-ringing',\n",
       " 'changed',\n",
       " 'changing',\n",
       " 'characterized',\n",
       " 'characterizing',\n",
       " 'charged',\n",
       " 'charging',\n",
       " 'chastised',\n",
       " 'cheating',\n",
       " 'checking',\n",
       " 'cheerleading',\n",
       " 'chilled',\n",
       " 'choosing',\n",
       " 'chopped',\n",
       " 'circulated',\n",
       " 'cited',\n",
       " 'citing',\n",
       " 'citizen-sparked',\n",
       " 'city-owned',\n",
       " 'claimed',\n",
       " 'claiming',\n",
       " 'clamped',\n",
       " 'clarified',\n",
       " 'clashed',\n",
       " 'classed',\n",
       " 'classified',\n",
       " 'cleaned',\n",
       " 'cleaner-burning',\n",
       " 'cleared',\n",
       " 'clearing',\n",
       " 'clicked',\n",
       " 'climbed',\n",
       " 'climbing',\n",
       " 'clipped',\n",
       " 'clobbered',\n",
       " 'closed',\n",
       " 'closing',\n",
       " 'clothing',\n",
       " 'clouding',\n",
       " 'cluttered',\n",
       " 'co-founded',\n",
       " 'coaching',\n",
       " 'coal-fired',\n",
       " 'coated',\n",
       " 'codified',\n",
       " 'collaborated',\n",
       " 'collapsed',\n",
       " 'collected',\n",
       " 'collecting',\n",
       " 'collective-bargaining',\n",
       " 'colored',\n",
       " 'combined',\n",
       " 'coming',\n",
       " 'commanded',\n",
       " 'commenting',\n",
       " 'committed',\n",
       " 'committing',\n",
       " 'compared',\n",
       " 'compelling',\n",
       " 'competed',\n",
       " 'competing',\n",
       " 'compiled',\n",
       " 'complained',\n",
       " 'complaining',\n",
       " 'completed',\n",
       " 'completing',\n",
       " 'complicated',\n",
       " 'composed',\n",
       " 'composting',\n",
       " 'compressed',\n",
       " 'computer-aided',\n",
       " 'computer-assisted',\n",
       " 'computer-generated',\n",
       " 'computerized',\n",
       " 'computing',\n",
       " 'conceding',\n",
       " 'concentrated',\n",
       " 'concentrating',\n",
       " 'concerned',\n",
       " 'concluded',\n",
       " 'condemned',\n",
       " 'condemning',\n",
       " 'conducted',\n",
       " 'conducting',\n",
       " 'confined',\n",
       " 'confirmed',\n",
       " 'confused',\n",
       " 'connected',\n",
       " 'consented',\n",
       " 'considered',\n",
       " 'considering',\n",
       " 'consisting',\n",
       " 'construed',\n",
       " 'consulting',\n",
       " 'contacted',\n",
       " 'contained',\n",
       " 'containing',\n",
       " 'contesting',\n",
       " 'continued',\n",
       " 'continuing',\n",
       " 'contracted',\n",
       " 'contributed',\n",
       " 'contributing',\n",
       " 'controlled',\n",
       " 'controlling',\n",
       " 'converted',\n",
       " 'converting',\n",
       " 'convicted',\n",
       " 'convinced',\n",
       " 'cooled',\n",
       " 'cooperating',\n",
       " 'copied',\n",
       " 'copying',\n",
       " 'corn-buying',\n",
       " 'corrected',\n",
       " 'correcting',\n",
       " 'cost-cutting',\n",
       " 'cost-sharing',\n",
       " 'counseling',\n",
       " 'counting',\n",
       " 'coupled',\n",
       " 'court-ordered',\n",
       " 'covered',\n",
       " 'covering',\n",
       " 'cranked',\n",
       " 'crashing',\n",
       " 'created',\n",
       " 'creating',\n",
       " 'credit-rating',\n",
       " 'crippled',\n",
       " 'criticized',\n",
       " 'crossed',\n",
       " 'crossing',\n",
       " 'crowded',\n",
       " 'cruising',\n",
       " 'crushed',\n",
       " 'crying',\n",
       " 'cultivated',\n",
       " 'curbed',\n",
       " 'curbing',\n",
       " 'curled',\n",
       " 'current-carrying',\n",
       " 'curtailed',\n",
       " 'cushioned',\n",
       " 'customized',\n",
       " 'cutting',\n",
       " 'damaged',\n",
       " 'damaging',\n",
       " 'dancing',\n",
       " 'darned',\n",
       " 'dashed',\n",
       " 'dating',\n",
       " 'dead-eyed',\n",
       " 'dealing',\n",
       " 'decided',\n",
       " 'declared',\n",
       " 'declaring',\n",
       " 'declined',\n",
       " 'declining',\n",
       " 'decorated',\n",
       " 'decried',\n",
       " 'deducting',\n",
       " 'deemed',\n",
       " 'defeated',\n",
       " 'defended',\n",
       " 'defined',\n",
       " 'defying',\n",
       " 'delayed',\n",
       " 'deliberating',\n",
       " 'delisted',\n",
       " 'delivered',\n",
       " 'delivering',\n",
       " 'demanding',\n",
       " 'demonstrating',\n",
       " 'denied',\n",
       " 'denouncing',\n",
       " 'denying',\n",
       " 'depended',\n",
       " 'depending',\n",
       " 'depleted',\n",
       " 'depressed',\n",
       " 'deprived',\n",
       " 'derived',\n",
       " 'descending',\n",
       " 'described',\n",
       " 'deserving',\n",
       " 'designated',\n",
       " 'designed',\n",
       " 'designing',\n",
       " 'desired',\n",
       " 'despised',\n",
       " 'detailed',\n",
       " 'deteriorated',\n",
       " 'deteriorating',\n",
       " 'determined',\n",
       " 'deterring',\n",
       " 'devastating',\n",
       " 'developed',\n",
       " 'developing',\n",
       " 'devised',\n",
       " 'devoted',\n",
       " 'devouring',\n",
       " 'diagnosed',\n",
       " 'died',\n",
       " 'diluted',\n",
       " 'diming',\n",
       " 'diminished',\n",
       " 'directed',\n",
       " 'directing',\n",
       " 'disaffected',\n",
       " 'disagreed',\n",
       " 'disappointed',\n",
       " 'disappointing',\n",
       " 'disapproved',\n",
       " 'discarded',\n",
       " 'disciplined',\n",
       " 'disclosed',\n",
       " 'disclosing',\n",
       " 'discontinued',\n",
       " 'discontinuing',\n",
       " 'discouraging',\n",
       " 'discovered',\n",
       " 'discussed',\n",
       " 'discussing',\n",
       " 'disembodied',\n",
       " 'dismayed',\n",
       " 'dismissed',\n",
       " 'disposed',\n",
       " 'disputed',\n",
       " 'disseminating',\n",
       " 'distinguished',\n",
       " 'distorted',\n",
       " 'distributed',\n",
       " 'disturbing',\n",
       " 'diversified',\n",
       " 'diversifying',\n",
       " 'divided',\n",
       " 'dividing',\n",
       " 'documented',\n",
       " 'doing',\n",
       " 'doling',\n",
       " 'dollar-denominated',\n",
       " 'dominated',\n",
       " 'dominating',\n",
       " 'doubled',\n",
       " 'doubted',\n",
       " 'downgraded',\n",
       " 'downgrading',\n",
       " 'drafted',\n",
       " 'drawing',\n",
       " 'dreamed',\n",
       " 'dressed',\n",
       " 'drifted',\n",
       " 'drinking',\n",
       " 'driving',\n",
       " 'drooled',\n",
       " 'dropped',\n",
       " 'dubbed',\n",
       " 'duckling',\n",
       " 'dumbfounded',\n",
       " 'dumped',\n",
       " 'during',\n",
       " 'dwindling',\n",
       " 'earned',\n",
       " 'earning',\n",
       " 'eased',\n",
       " 'easing',\n",
       " 'eating',\n",
       " 'echoed',\n",
       " 'edged',\n",
       " 'editing',\n",
       " 'educated',\n",
       " 'elected',\n",
       " 'eliminated',\n",
       " 'eliminating',\n",
       " 'embarrassing',\n",
       " 'embroiled',\n",
       " 'emerged',\n",
       " 'emerging',\n",
       " 'emphasized',\n",
       " 'employed',\n",
       " 'empowered',\n",
       " 'enabled',\n",
       " 'enabling',\n",
       " 'enacted',\n",
       " 'encircling',\n",
       " 'enclosed',\n",
       " 'encouraging',\n",
       " 'encroaching',\n",
       " 'ended',\n",
       " 'ending',\n",
       " 'endorsed',\n",
       " 'engaged',\n",
       " 'engaging',\n",
       " 'engineered',\n",
       " 'engineering',\n",
       " 'enhanced',\n",
       " 'enjoyed',\n",
       " 'enjoying',\n",
       " 'enlarged',\n",
       " 'enraged',\n",
       " 'ensnarled',\n",
       " 'entangled',\n",
       " 'entered',\n",
       " 'entering',\n",
       " 'entertaining',\n",
       " 'enticed',\n",
       " 'entitled',\n",
       " 'entrenched',\n",
       " 'entrusted',\n",
       " 'equaling',\n",
       " 'equipped',\n",
       " 'escalated',\n",
       " 'escaped',\n",
       " 'established',\n",
       " 'establishing',\n",
       " 'estimated',\n",
       " 'evaluated',\n",
       " 'evaluating',\n",
       " 'evaporated',\n",
       " 'evening',\n",
       " 'everything',\n",
       " 'evoking',\n",
       " 'evolved',\n",
       " 'exacerbated',\n",
       " 'examined',\n",
       " 'exceed',\n",
       " 'exceeded',\n",
       " 'exceeding',\n",
       " 'exchanging',\n",
       " 'excited',\n",
       " 'exciting',\n",
       " 'executed',\n",
       " 'executing',\n",
       " 'exercised',\n",
       " 'exerting',\n",
       " 'exhausted',\n",
       " 'exhibited',\n",
       " 'existed',\n",
       " 'existing',\n",
       " 'expanded',\n",
       " 'expanding',\n",
       " 'expected',\n",
       " 'expecting',\n",
       " 'expedited',\n",
       " 'expelled',\n",
       " 'experienced',\n",
       " 'experiencing',\n",
       " 'expired',\n",
       " 'explained',\n",
       " 'explaining',\n",
       " 'exploded',\n",
       " 'export-oriented',\n",
       " 'exposed',\n",
       " 'expressed',\n",
       " 'expressing',\n",
       " 'expunged',\n",
       " 'extended',\n",
       " 'extending',\n",
       " 'exuded',\n",
       " 'eyeing',\n",
       " 'fabled',\n",
       " 'faced',\n",
       " 'facing',\n",
       " 'factoring',\n",
       " 'faded',\n",
       " 'failed',\n",
       " 'failing',\n",
       " 'fainting',\n",
       " 'falling',\n",
       " 'faltered',\n",
       " 'famed',\n",
       " 'family-planning',\n",
       " 'fared',\n",
       " 'fashioned',\n",
       " 'fast-growing',\n",
       " 'fastest-growing',\n",
       " 'fattened',\n",
       " 'favored',\n",
       " 'fawning',\n",
       " 'feared',\n",
       " 'featured',\n",
       " 'featuring',\n",
       " 'fed',\n",
       " 'feed',\n",
       " 'feeling',\n",
       " 'fetching',\n",
       " 'fielded',\n",
       " 'fighting',\n",
       " 'filed',\n",
       " 'filing',\n",
       " 'filled',\n",
       " 'filling',\n",
       " 'finalized',\n",
       " 'financed',\n",
       " 'financing',\n",
       " 'finding',\n",
       " 'fined',\n",
       " 'finished',\n",
       " 'fired',\n",
       " 'firmed',\n",
       " 'fixed',\n",
       " 'fizzled',\n",
       " 'fled',\n",
       " 'fledgling',\n",
       " 'fleeting',\n",
       " 'flirted',\n",
       " 'floated',\n",
       " 'flooded',\n",
       " 'focused',\n",
       " 'focusing',\n",
       " 'folded',\n",
       " 'followed',\n",
       " 'following',\n",
       " 'forced',\n",
       " 'forcing',\n",
       " 'forecasting',\n",
       " 'foreign-led',\n",
       " 'formed',\n",
       " 'forthcoming',\n",
       " 'founded',\n",
       " 'foundering',\n",
       " 'fretted',\n",
       " 'frightened',\n",
       " 'frustrating',\n",
       " 'fueled',\n",
       " 'fueling',\n",
       " 'full-fledged',\n",
       " 'fuming',\n",
       " 'functioning',\n",
       " 'funded',\n",
       " 'funding',\n",
       " 'fundraising',\n",
       " 'futures-related',\n",
       " 'gained',\n",
       " 'gaining',\n",
       " 'galling',\n",
       " 'galvanized',\n",
       " 'gambling',\n",
       " 'gauging',\n",
       " 'generated',\n",
       " 'getting',\n",
       " 'giving',\n",
       " 'going',\n",
       " 'good-hearted',\n",
       " 'good-natured',\n",
       " 'gored',\n",
       " 'government-certified',\n",
       " 'government-funded',\n",
       " 'government-owned',\n",
       " 'graduated',\n",
       " 'granted',\n",
       " 'granting',\n",
       " 'greed',\n",
       " 'gripping',\n",
       " 'growing',\n",
       " 'guaranteed',\n",
       " 'guarding',\n",
       " 'guided',\n",
       " 'gut-wrenching',\n",
       " 'hailed',\n",
       " 'hailing',\n",
       " 'halted',\n",
       " 'hampered',\n",
       " 'handed',\n",
       " 'handled',\n",
       " 'handling',\n",
       " 'happened',\n",
       " 'happening',\n",
       " 'hard-charging',\n",
       " 'hard-drinking',\n",
       " 'hard-hitting',\n",
       " 'harmed',\n",
       " 'harped',\n",
       " 'harvested',\n",
       " 'hauled',\n",
       " 'hauling',\n",
       " 'having',\n",
       " 'headed',\n",
       " 'heading',\n",
       " 'headlined',\n",
       " 'healing',\n",
       " 'hearing',\n",
       " 'heated',\n",
       " 'heating',\n",
       " 'hedging',\n",
       " 'heightened',\n",
       " 'helped',\n",
       " 'helping',\n",
       " 'high-flying',\n",
       " 'high-minded',\n",
       " 'high-polluting',\n",
       " 'high-priced',\n",
       " 'high-rolling',\n",
       " 'high-speed',\n",
       " 'higher-salaried',\n",
       " 'highest-pitched',\n",
       " 'hired',\n",
       " 'hitting',\n",
       " 'holding',\n",
       " 'hoped',\n",
       " 'hosted',\n",
       " 'housing',\n",
       " 'hugging',\n",
       " 'hundred',\n",
       " 'hunted',\n",
       " 'hurting',\n",
       " 'identified',\n",
       " 'ignored',\n",
       " 'ignoring',\n",
       " 'impaired',\n",
       " 'impeding',\n",
       " 'impending',\n",
       " 'implemented',\n",
       " 'implied',\n",
       " 'imported',\n",
       " 'imposed',\n",
       " 'imposing',\n",
       " 'impressed',\n",
       " 'improved',\n",
       " 'improving',\n",
       " 'incentive-backed',\n",
       " 'inched',\n",
       " 'inching',\n",
       " 'included',\n",
       " 'including',\n",
       " 'incorporated',\n",
       " 'increased',\n",
       " 'increasing',\n",
       " 'incurred',\n",
       " 'indeed',\n",
       " 'index-related',\n",
       " 'indicated',\n",
       " 'indicating',\n",
       " 'indulging',\n",
       " 'industrialized',\n",
       " 'industry-supported',\n",
       " 'inflated',\n",
       " 'influenced',\n",
       " 'influencing',\n",
       " 'infringed',\n",
       " 'inherited',\n",
       " 'initialing',\n",
       " 'initiated',\n",
       " 'initiating',\n",
       " 'injecting',\n",
       " 'injuring',\n",
       " 'inkling',\n",
       " 'inquiring',\n",
       " 'inserted',\n",
       " 'insider-trading',\n",
       " 'insinuating',\n",
       " 'insisted',\n",
       " 'inspired',\n",
       " 'installed',\n",
       " 'installing',\n",
       " 'instituted',\n",
       " 'instructed',\n",
       " 'insured',\n",
       " 'integrated',\n",
       " 'intended',\n",
       " 'intentioned',\n",
       " 'interest-bearing',\n",
       " 'interested',\n",
       " 'interesting',\n",
       " 'interrogated',\n",
       " 'interviewed',\n",
       " 'intriguing',\n",
       " 'introduced',\n",
       " 'introducing',\n",
       " 'invented',\n",
       " 'inverted',\n",
       " 'invested',\n",
       " 'investigating',\n",
       " 'investing',\n",
       " 'inviting',\n",
       " 'involved',\n",
       " 'involving',\n",
       " 'issued',\n",
       " 'issuing',\n",
       " 'jeopardizing',\n",
       " 'joined',\n",
       " 'joining',\n",
       " 'judged',\n",
       " 'jumped',\n",
       " 'jumping',\n",
       " 'justified',\n",
       " 'justifying',\n",
       " 'keeping',\n",
       " 'kicked',\n",
       " 'kidnapping',\n",
       " 'killed',\n",
       " 'killing',\n",
       " 'knitted',\n",
       " 'knocked',\n",
       " 'labeled',\n",
       " 'labeling',\n",
       " 'labor-backed',\n",
       " 'lacked',\n",
       " 'lagging',\n",
       " 'land-idling',\n",
       " 'landing',\n",
       " 'lasted',\n",
       " 'lasting',\n",
       " 'lauded',\n",
       " 'laughing',\n",
       " 'launched',\n",
       " 'lawmaking',\n",
       " 'laying',\n",
       " 'leading',\n",
       " 'learned',\n",
       " 'learning',\n",
       " 'leasing',\n",
       " 'leaving',\n",
       " 'led',\n",
       " 'lending',\n",
       " 'lengthened',\n",
       " 'lessening',\n",
       " 'letter-writing',\n",
       " 'letting',\n",
       " 'leveling',\n",
       " 'leveraged',\n",
       " 'leveraging',\n",
       " 'licensed',\n",
       " 'licensing',\n",
       " 'lifted',\n",
       " ...]"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[w for w in wsj if re.search(\"(ed|ing)$\", w)] # (ed|ing) 表示匹配已组合ed或者ing结尾的单词"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 124,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Biedermann\n",
      "Breeden\n",
      "Cathedral\n",
      "Cedric\n",
      "Confederation\n",
      "Credit\n",
      "Federal\n",
      "Federalist\n",
      "Federation\n",
      "Freddie\n",
      "Frederick\n",
      "Friedrichs\n",
      "Impediments\n",
      "Intermediate\n",
      "Kennedy\n",
      "Media\n",
      "Medical\n",
      "Medicine\n",
      "Mercedes\n",
      "Montedison\n",
      "Nederlanden\n",
      "Needham\n",
      "Proceeds\n",
      "Reddington\n",
      "Redevelopment\n",
      "Roederer\n",
      "Speedway\n",
      "Sweden\n",
      "Teddy\n",
      "Toledo\n",
      "Wednesday\n",
      "Wedtech\n",
      "acknowledge\n",
      "acknowledges\n",
      "agreed-upon\n",
      "allegedly\n",
      "beds\n",
      "buttoned-down\n",
      "closed-end\n",
      "comedies\n",
      "concede\n",
      "concedes\n",
      "credentials\n",
      "credibility\n",
      "credit\n",
      "creditor\n",
      "creditors\n",
      "credits\n",
      "creditworthiness\n",
      "deeds\n",
      "discredit\n",
      "edition\n",
      "editions\n",
      "editor\n",
      "editorial\n",
      "editorially\n",
      "editors\n",
      "education\n",
      "educational\n",
      "educators\n",
      "exceedingly\n",
      "exceeds\n",
      "federal\n",
      "federally\n",
      "feeds\n",
      "fixed-income\n",
      "fixed-price\n",
      "fixed-rate\n",
      "freedom\n",
      "freedoms\n",
      "greedy\n",
      "hundreds\n",
      "immediate\n",
      "immediately\n",
      "impede\n",
      "incredible\n",
      "ingredients\n",
      "intermediate\n",
      "knowledge\n",
      "knowledgeable\n",
      "limited-partnership\n",
      "medallions\n",
      "media\n",
      "medical\n",
      "medicine\n",
      "mediocre\n",
      "needle-like\n",
      "needs\n",
      "needy\n",
      "obedient\n",
      "pediatrician\n",
      "pianist-comedian\n",
      "precedent\n",
      "precedes\n",
      "predecessor\n",
      "predict\n",
      "predictable\n",
      "predictably\n",
      "predicts\n",
      "predispose\n",
      "procedural\n",
      "procedure\n",
      "procedures\n",
      "proceedings\n",
      "proceeds\n",
      "recede\n",
      "red-and-white\n",
      "red-carpet\n",
      "red-flag\n",
      "redeem\n",
      "redemption\n",
      "redeploy\n",
      "redistribute\n",
      "reds\n",
      "reduce\n",
      "reduction\n",
      "reductions\n",
      "repeatedly\n",
      "reportedly\n",
      "schedule\n",
      "secede\n",
      "seduce\n",
      "single-handedly\n",
      "speedway\n",
      "staff-reduction\n",
      "succeeds\n",
      "supposedly\n",
      "weddings\n"
     ]
    }
   ],
   "source": [
    "for i in [w for w in wsj if re.search(\"ed|ing$\", w)]:                # 不加() 只要遇到ed就匹配截止\n",
    "    if i not in [w for w in wsj if re.search(\"(ed|ing)$\", w)]:\n",
    "        print (i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 126,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Hymowitz',\n",
       " 'Switzerland',\n",
       " 'awaits',\n",
       " 'bellwether',\n",
       " 'notwithstanding',\n",
       " 'switch',\n",
       " 'switched',\n",
       " 'wait',\n",
       " 'waited',\n",
       " 'waiting',\n",
       " 'wherewithal',\n",
       " 'witches',\n",
       " 'with',\n",
       " 'withdraw',\n",
       " 'withdrawal',\n",
       " 'withdrawn',\n",
       " 'withdrew',\n",
       " 'withhold',\n",
       " 'within',\n",
       " 'without',\n",
       " 'withstand',\n",
       " 'witness',\n",
       " 'witnesses']"
      ]
     },
     "execution_count": 126,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[w for w in wsj if re.search(\"w(i|e|ai|oo)t\", w)] # 匹配含有wit，wet，wait，woot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['u',\n",
       " 'e',\n",
       " 'a',\n",
       " 'i',\n",
       " 'a',\n",
       " 'i',\n",
       " 'i',\n",
       " 'i',\n",
       " 'e',\n",
       " 'i',\n",
       " 'a',\n",
       " 'i',\n",
       " 'o',\n",
       " 'i',\n",
       " 'o',\n",
       " 'u']"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "word = \"supercalifragilisticexpialidocious\"\n",
    "re.findall(r\"[aeiou]\", word)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('ia', 12408), ('iou', 12408)]"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 看看一些文本中的两个或两个以上的元音序列，并确定它们的相对频率：\n",
    "wsj = sorted(set(nltk.corpus.treebank.words()))\n",
    "fd = nltk.FreqDist(vs for vs in re.findall(r\"[aeiou]{2,}\", word)  for word in wsj)\n",
    "fd.most_common(12)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('io', 549),\n",
       " ('ea', 476),\n",
       " ('ie', 331),\n",
       " ('ou', 329),\n",
       " ('ai', 261),\n",
       " ('ia', 253),\n",
       " ('ee', 217),\n",
       " ('oo', 174),\n",
       " ('ua', 109),\n",
       " ('au', 106),\n",
       " ('ue', 105),\n",
       " ('ui', 95)]"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> wsj = sorted(set(nltk.corpus.treebank.words()))\n",
    ">>> fd = nltk.FreqDist(vs for word in wsj for vs in re.findall(r'[aeiou]{2,}', word))\n",
    ">>> fd.most_common(12)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['ea',\n",
       " 'oi',\n",
       " 'ea',\n",
       " 'ou',\n",
       " 'oi',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'oi',\n",
       " 'oi',\n",
       " 'ea',\n",
       " 'io',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'oi',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ee',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'oi',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ie',\n",
       " 'ui',\n",
       " 'io',\n",
       " 'ua',\n",
       " 'io',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'io',\n",
       " 'ie',\n",
       " 'ue',\n",
       " 'ue',\n",
       " 'ia',\n",
       " 'ie',\n",
       " 'ea',\n",
       " 'ai',\n",
       " 'ou',\n",
       " 'ia',\n",
       " 'ei',\n",
       " 'ie',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ie',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ua',\n",
       " 'ie',\n",
       " 'io',\n",
       " 'ea',\n",
       " 'ia',\n",
       " 'io',\n",
       " 'ui',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ea',\n",
       " 'iai',\n",
       " 'ai',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'io',\n",
       " 'oo',\n",
       " 'io',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ue',\n",
       " 'ea',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ue',\n",
       " 'ie',\n",
       " 'au',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'eau',\n",
       " 'au',\n",
       " 'ei',\n",
       " 'ei',\n",
       " 'ei',\n",
       " 'ei',\n",
       " 'ei',\n",
       " 'ia',\n",
       " 'ie',\n",
       " 'io',\n",
       " 'ue',\n",
       " 'oa',\n",
       " 'oei',\n",
       " 'oe',\n",
       " 'ia',\n",
       " 'oo',\n",
       " 'oo',\n",
       " 'oo',\n",
       " 'eau',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ai',\n",
       " 'ou',\n",
       " 'ai',\n",
       " 'oo',\n",
       " 'ea',\n",
       " 'au',\n",
       " 'ia',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ee',\n",
       " 'ia',\n",
       " 'ai',\n",
       " 'oa',\n",
       " 'oo',\n",
       " 'oo',\n",
       " 'oo',\n",
       " 'ei',\n",
       " 'ei',\n",
       " 'ea',\n",
       " 'ui',\n",
       " 'ui',\n",
       " 'eau',\n",
       " 'ie',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ai',\n",
       " 'eau',\n",
       " 'ia',\n",
       " 'ea',\n",
       " 'ie',\n",
       " 'ie',\n",
       " 'oo',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'io',\n",
       " 'ie',\n",
       " 'ie',\n",
       " 'eau',\n",
       " 'ee',\n",
       " 'ee',\n",
       " 'ea',\n",
       " 'io',\n",
       " 'oo',\n",
       " 'ia',\n",
       " 'ie',\n",
       " 'ui',\n",
       " 'io',\n",
       " 'io',\n",
       " 'io',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'au',\n",
       " 'oa',\n",
       " 'oi',\n",
       " 'ia',\n",
       " 'io',\n",
       " 'io',\n",
       " 'ee',\n",
       " 'ie',\n",
       " 'ea',\n",
       " 'io',\n",
       " 'io',\n",
       " 'ie',\n",
       " 'ou',\n",
       " 'io',\n",
       " 'io',\n",
       " 'ue',\n",
       " 'io',\n",
       " 'io',\n",
       " 'ai',\n",
       " 'ue',\n",
       " 'ui',\n",
       " 'io',\n",
       " 'oo',\n",
       " 'oo',\n",
       " 'io',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ie',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ee',\n",
       " 'ui',\n",
       " 'ee',\n",
       " 'ia',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ie',\n",
       " 'ie',\n",
       " 'oi',\n",
       " 'ie',\n",
       " 'io',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ee',\n",
       " 'au',\n",
       " 'io',\n",
       " 'ai',\n",
       " 'io',\n",
       " 'oi',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'eo',\n",
       " 'ie',\n",
       " 'ea',\n",
       " 'io',\n",
       " 'oa',\n",
       " 'oe',\n",
       " 'ai',\n",
       " 'io',\n",
       " 'ie',\n",
       " 'ue',\n",
       " 'ou',\n",
       " 'oi',\n",
       " 'ue',\n",
       " 'ee',\n",
       " 'ie',\n",
       " 'ia',\n",
       " 'ie',\n",
       " 'io',\n",
       " 'io',\n",
       " 'ia',\n",
       " 'io',\n",
       " 'ie',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ee',\n",
       " 'ea',\n",
       " 'ai',\n",
       " 'ua',\n",
       " 'ui',\n",
       " 'ui',\n",
       " 'ui',\n",
       " 'uu',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'io',\n",
       " 'ui',\n",
       " 'ie',\n",
       " 'ia',\n",
       " 'ie',\n",
       " 'ie',\n",
       " 'ei',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ie',\n",
       " 'au',\n",
       " 'ea',\n",
       " 'ua',\n",
       " 'io',\n",
       " 'ee',\n",
       " 'ee',\n",
       " 'ie',\n",
       " 'ee',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'io',\n",
       " 'oo',\n",
       " 'oo',\n",
       " 'oo',\n",
       " 'ei',\n",
       " 'ei',\n",
       " 'ou',\n",
       " 'io',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ai',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ee',\n",
       " 'ou',\n",
       " 'ie',\n",
       " 'ee',\n",
       " 'ee',\n",
       " 'eu',\n",
       " 'eu',\n",
       " 'ie',\n",
       " 'ie',\n",
       " 'ue',\n",
       " 'ai',\n",
       " 'ie',\n",
       " 'eo',\n",
       " 'eo',\n",
       " 'eo',\n",
       " 'ia',\n",
       " 'eo',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ie',\n",
       " 'ie',\n",
       " 'au',\n",
       " 'iu',\n",
       " 'ia',\n",
       " 'au',\n",
       " 'oo',\n",
       " 'oo',\n",
       " 'ie',\n",
       " 'ua',\n",
       " 'ua',\n",
       " 'ai',\n",
       " 'ea',\n",
       " 'ee',\n",
       " 'ee',\n",
       " 'ee',\n",
       " 'ee',\n",
       " 'ee',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ua',\n",
       " 'ee',\n",
       " 'ua',\n",
       " 'ee',\n",
       " 'ua',\n",
       " 'ue',\n",
       " 'ui',\n",
       " 'ui',\n",
       " 'ui',\n",
       " 'ea',\n",
       " 'oo',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'au',\n",
       " 'io',\n",
       " 'aii',\n",
       " 'aiia',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ei',\n",
       " 'ei',\n",
       " 'ei',\n",
       " 'ei',\n",
       " 'oo',\n",
       " 'ie',\n",
       " 'oo',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ea',\n",
       " 'oi',\n",
       " 'ee',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ua',\n",
       " 'ua',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ie',\n",
       " 'io',\n",
       " 'ia',\n",
       " 'ou',\n",
       " 'ea',\n",
       " 'io',\n",
       " 'io',\n",
       " 'eu',\n",
       " 'ia',\n",
       " 'io',\n",
       " 'ie',\n",
       " 'ia',\n",
       " 'ie',\n",
       " 'ae',\n",
       " 'ue',\n",
       " 'ia',\n",
       " 'ua',\n",
       " 'ai',\n",
       " 'aa',\n",
       " 'aa',\n",
       " 'ai',\n",
       " 'ua',\n",
       " 'oa',\n",
       " 'oe',\n",
       " 'oe',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ie',\n",
       " 'ia',\n",
       " 'oo',\n",
       " 'ee',\n",
       " 'ei',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ee',\n",
       " 'ei',\n",
       " 'ei',\n",
       " 'ee',\n",
       " 'au',\n",
       " 'ei',\n",
       " 'oi',\n",
       " 'oi',\n",
       " 'ea',\n",
       " 'ua',\n",
       " 'ie',\n",
       " 'oui',\n",
       " 'ieu',\n",
       " 'ou',\n",
       " 'au',\n",
       " 'au',\n",
       " 'au',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ee',\n",
       " 'ou',\n",
       " 'io',\n",
       " 'ei',\n",
       " 'ei',\n",
       " 'ei',\n",
       " 'eo',\n",
       " 'eo',\n",
       " 'io',\n",
       " 'ie',\n",
       " 'ou',\n",
       " 'oa',\n",
       " 'oe',\n",
       " 'oe',\n",
       " 'oo',\n",
       " 'ai',\n",
       " 'oui',\n",
       " 'oui',\n",
       " 'ia',\n",
       " 'oui',\n",
       " 'ia',\n",
       " 'oui',\n",
       " 'ie',\n",
       " 'ae',\n",
       " 'ai',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ie',\n",
       " 'ie',\n",
       " 'oui',\n",
       " 'ie',\n",
       " 'io',\n",
       " 'io',\n",
       " 'io',\n",
       " 'ia',\n",
       " 'au',\n",
       " 'ui',\n",
       " 'eo',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ia',\n",
       " 'ee',\n",
       " 'ei',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ae',\n",
       " 'ae',\n",
       " 'io',\n",
       " 'ue',\n",
       " 'ai',\n",
       " 'au',\n",
       " 'ee',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'io',\n",
       " 'ou',\n",
       " 'ui',\n",
       " 'io',\n",
       " 'oi',\n",
       " 'ou',\n",
       " 'ie',\n",
       " 'oo',\n",
       " 'oo',\n",
       " 'oo',\n",
       " 'eo',\n",
       " 'ou',\n",
       " 'ua',\n",
       " 'oi',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'io',\n",
       " 'io',\n",
       " 'io',\n",
       " 'io',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ee',\n",
       " 'ia',\n",
       " 'ei',\n",
       " 'ei',\n",
       " 'oo',\n",
       " 'eu',\n",
       " 'ou',\n",
       " 'ee',\n",
       " 'ua',\n",
       " 'ie',\n",
       " 'ei',\n",
       " 'ai',\n",
       " 'ie',\n",
       " 'ea',\n",
       " 'ia',\n",
       " 'ou',\n",
       " 'ie',\n",
       " 'ou',\n",
       " 'ei',\n",
       " 'io',\n",
       " 'io',\n",
       " 'ea',\n",
       " 'ia',\n",
       " 'io',\n",
       " 'io',\n",
       " 'ou',\n",
       " 'ia',\n",
       " 'io',\n",
       " 'io',\n",
       " 'io',\n",
       " 'io',\n",
       " 'io',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ai',\n",
       " 'ia',\n",
       " 'ua',\n",
       " 'ou',\n",
       " 'ia',\n",
       " 'ie',\n",
       " 'ia',\n",
       " 'au',\n",
       " 'au',\n",
       " 'ou',\n",
       " 'ea',\n",
       " 'ia',\n",
       " 'ie',\n",
       " 'eo',\n",
       " 'eo',\n",
       " 'ia',\n",
       " 'oi',\n",
       " 'io',\n",
       " 'ua',\n",
       " 'eu',\n",
       " 'ao',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'oe',\n",
       " 'ie',\n",
       " 'ie',\n",
       " 'io',\n",
       " 'ai',\n",
       " 'io',\n",
       " 'ie',\n",
       " 'oo',\n",
       " 'oo',\n",
       " 'io',\n",
       " 'ua',\n",
       " 'iou',\n",
       " 'ie',\n",
       " 'ia',\n",
       " 'iou',\n",
       " 'io',\n",
       " 'ee',\n",
       " 'io',\n",
       " 'io',\n",
       " 'ua',\n",
       " 'io',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'io',\n",
       " 'io',\n",
       " 'ue',\n",
       " 'ua',\n",
       " 'uee',\n",
       " 'ia',\n",
       " 'io',\n",
       " 'ae',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'oa',\n",
       " 'ei',\n",
       " 'ie',\n",
       " 'au',\n",
       " 'oo',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'oo',\n",
       " 'ee',\n",
       " 'io',\n",
       " 'ia',\n",
       " 'ai',\n",
       " 'ee',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ou',\n",
       " 'au',\n",
       " 'ai',\n",
       " 'eu',\n",
       " 'eu',\n",
       " 'eu',\n",
       " 'ue',\n",
       " 'ie',\n",
       " 'io',\n",
       " 'ou',\n",
       " 'ie',\n",
       " 'ie',\n",
       " 'ie',\n",
       " 'ie',\n",
       " 'ie',\n",
       " 'oe',\n",
       " 'ee',\n",
       " 'oo',\n",
       " 'oo',\n",
       " 'oo',\n",
       " 'ie',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ie',\n",
       " 'ia',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ue',\n",
       " 'au',\n",
       " 'au',\n",
       " 'au',\n",
       " 'au',\n",
       " 'ia',\n",
       " 'ae',\n",
       " 'oo',\n",
       " 'ei',\n",
       " 'ie',\n",
       " 'ie',\n",
       " 'ia',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'io',\n",
       " 'ie',\n",
       " 'ee',\n",
       " 'ou',\n",
       " 'io',\n",
       " 'io',\n",
       " 'eou',\n",
       " 'ia',\n",
       " 'ie',\n",
       " 'io',\n",
       " 'ou',\n",
       " 'ea',\n",
       " 'ee',\n",
       " 'ie',\n",
       " 'oo',\n",
       " 'ai',\n",
       " 'ia',\n",
       " 'ie',\n",
       " 'ie',\n",
       " 'eo',\n",
       " 'ie',\n",
       " 'oa',\n",
       " 'ia',\n",
       " 'ie',\n",
       " 'aia',\n",
       " 'io',\n",
       " 'oo',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ea',\n",
       " 'ou',\n",
       " 'ie',\n",
       " 'ie',\n",
       " 'ai',\n",
       " 'io',\n",
       " 'ee',\n",
       " 'ie',\n",
       " 'ie',\n",
       " 'oo',\n",
       " 'ea',\n",
       " 'ie',\n",
       " 'uie',\n",
       " 'iu',\n",
       " 'iu',\n",
       " 'ea',\n",
       " 'ee',\n",
       " 'ee',\n",
       " 'ei',\n",
       " 'ie',\n",
       " 'ie',\n",
       " 'ie',\n",
       " 'ai',\n",
       " 'ee',\n",
       " 'ua',\n",
       " 'ui',\n",
       " 'ai',\n",
       " 'ea',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ei',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'eo',\n",
       " 'au',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ei',\n",
       " 'io',\n",
       " 'io',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ei',\n",
       " 'eo',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ee',\n",
       " 'oo',\n",
       " 'io',\n",
       " 'oo',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'io',\n",
       " 'io',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'io',\n",
       " 'ea',\n",
       " 'ie',\n",
       " 'ee',\n",
       " 'au',\n",
       " 'ou',\n",
       " 'eau',\n",
       " 'ue',\n",
       " 'ou',\n",
       " 'ai',\n",
       " 'oo',\n",
       " 'oo',\n",
       " 'io',\n",
       " 'ie',\n",
       " 'ie',\n",
       " 'ue',\n",
       " 'ia',\n",
       " 'eo',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ua',\n",
       " 'oi',\n",
       " 'ae',\n",
       " 'ae',\n",
       " 'ui',\n",
       " 'ou',\n",
       " 'oo',\n",
       " 'ea',\n",
       " 'ee',\n",
       " 'ei',\n",
       " 'ei',\n",
       " 'ie',\n",
       " 'ei',\n",
       " 'ou',\n",
       " 'ee',\n",
       " 'ea',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ou',\n",
       " 'oo',\n",
       " 'oo',\n",
       " 'oo',\n",
       " 'oo',\n",
       " 'oo',\n",
       " 'ee',\n",
       " 'ia',\n",
       " 'iao',\n",
       " 'ai',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ie',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ue',\n",
       " 'ea',\n",
       " 'oa',\n",
       " 'io',\n",
       " 'io',\n",
       " 'io',\n",
       " 'io',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'oa',\n",
       " 'io',\n",
       " 'ie',\n",
       " 'io',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ue',\n",
       " 'ue',\n",
       " 'ie',\n",
       " 'ie',\n",
       " 'ie',\n",
       " 'ie',\n",
       " 'ie',\n",
       " 'ai',\n",
       " 'ui',\n",
       " 'ui',\n",
       " 'ui',\n",
       " 'ui',\n",
       " 'ui',\n",
       " 'ui',\n",
       " 'ui',\n",
       " 'io',\n",
       " 'ui',\n",
       " 'io',\n",
       " 'ui',\n",
       " 'io',\n",
       " 'io',\n",
       " 'io',\n",
       " 'ie',\n",
       " 'ua',\n",
       " 'ua',\n",
       " 'io',\n",
       " 'io',\n",
       " 'io',\n",
       " 'io',\n",
       " 'ua',\n",
       " 'ua',\n",
       " 'io',\n",
       " 'io',\n",
       " 'ia',\n",
       " 'ae',\n",
       " 'ae',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ai',\n",
       " 'oo',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ie',\n",
       " 'ee',\n",
       " 'ee',\n",
       " 'ee',\n",
       " 'eei',\n",
       " 'ee',\n",
       " 'ee',\n",
       " 'ee',\n",
       " 'ea',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ai',\n",
       " 'ie',\n",
       " 'io',\n",
       " 'ia',\n",
       " 'ie',\n",
       " 'io',\n",
       " 'ea',\n",
       " 'ou',\n",
       " 'ui',\n",
       " 'io',\n",
       " 'iou',\n",
       " 'io',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ie',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ou',\n",
       " 'ua',\n",
       " 'ua',\n",
       " 'ua',\n",
       " 'io',\n",
       " 'io',\n",
       " 'ia',\n",
       " 'eo',\n",
       " 'io',\n",
       " 'ie',\n",
       " 'ie',\n",
       " 'iou',\n",
       " 'ie',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'au',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'io',\n",
       " 'io',\n",
       " 'ie',\n",
       " 'oi',\n",
       " 'oi',\n",
       " 'oi',\n",
       " 'oi',\n",
       " 'ia',\n",
       " 'io',\n",
       " 'oa',\n",
       " 'oa',\n",
       " 'oa',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'io',\n",
       " 'ia',\n",
       " 'io',\n",
       " 'ia',\n",
       " 'ea',\n",
       " 'ea',\n",
       " 'ue',\n",
       " 'ue',\n",
       " 'ue',\n",
       " 'ui',\n",
       " 'ou',\n",
       " 'io',\n",
       " 'au',\n",
       " 'au',\n",
       " 'io',\n",
       " 'io',\n",
       " 'ua',\n",
       " 'io',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'io',\n",
       " 'io',\n",
       " 'io',\n",
       " 'ie',\n",
       " 'io',\n",
       " 'au',\n",
       " 'io',\n",
       " 'au',\n",
       " ...]"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[vs for word in wsj for vs in re.findall(r'[aeiou]{2,}', word)]   # 疑问：for word in wsj 放在前边和放在后边为啥不一样？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " 'ia',\n",
       " ...]"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[vs for vs in re.findall(r'[aeiou]{2,}', word)  for word in wsj]   # 疑问：for word in wsj 放在前边和放在后边为啥不一样？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[2009, 12, 31]"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import re\n",
    "[int(n) for n in re.findall(\"[0-9]{2,}\", '2009-12-31')]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3、忽略掉词内部的元音\n",
    "英文文本是高度冗余的，忽略掉词内部的元音仍然可以很容易的阅读，有些时候这很明显。例如，declaration变成dclrtn，inalienable变成inlnble，保留所有词首或词尾的元音序列。在我们的下一个例子中，正则表达式匹配词首元音序列，词尾元音序列和所有的辅音；其它的被忽略。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['Universal', 'Declaration', 'of', 'Human', 'Rights', 'Preamble', 'Whereas', 'recognition', 'of', 'the', 'inherent', 'dignity', 'and', 'of', 'the', 'equal', 'and', 'inalienable', 'rights', 'of', 'all', 'members', 'of', 'the', 'human', 'family', 'is', 'the', 'foundation', 'of', 'freedom', ',', 'justice', 'and', 'peace', 'in', 'the', 'world', ',', 'Whereas', 'disregard', 'and', 'contempt', 'for', 'human', 'rights', 'have', 'resulted', 'in', 'barbarous', 'acts', 'which', 'have', 'outraged', 'the', 'conscience', 'of', 'mankind', ',', 'and', 'the', 'advent', 'of', 'a', 'world', 'in', 'which', 'human', 'beings', 'shall', 'enjoy', 'freedom', 'of', 'speech', 'and'] \n",
      "\n",
      "Unvrsl Dclrtn of Hmn Rghts Prmble Whrs rcgntn of the inhrnt dgnty and\n",
      "of the eql and inlnble rghts of all mmbrs of the hmn fmly is the fndtn\n",
      "of frdm , jstce and pce in the wrld , Whrs dsrgrd and cntmpt fr hmn\n",
      "rghts hve rsltd in brbrs acts whch hve outrgd the cnscnce of mnknd ,\n",
      "and the advnt of a wrld in whch hmn bngs shll enjy frdm of spch and\n"
     ]
    }
   ],
   "source": [
    "regexp = r\"^[AEIOUaeiou]+|[AEIOUaeiou]+$|[^AEIOUaeiou]\"\n",
    "def compress(word):\n",
    "    pieces = re.findall(regexp, word)\n",
    "    return \"\".join(pieces)\n",
    "english_udhr = nltk.corpus.udhr.words(\"English-Latin1\")\n",
    "print(english_udhr[:75],\"\\n\")\n",
    "print(nltk.tokenwrap(compress(w) for w in english_udhr[:75]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 4、将正则表达式与条件频率分布结合起来\n",
    "在这里，我们将从罗托卡特语词汇中提取所有辅音-元音序列，如ka和si。因为每部分都是成对的，它可以被用来初始化一个条件频率分布。然后我们为每对的频率画出表格："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['ka', 'ka', 'ka', 'ka', 'ka', 'ro', 'ka', 'ka', 'vi', 'ko']\n"
     ]
    }
   ],
   "source": [
    "rotokas_words = nltk.corpus.toolbox.words(\"rotokas.dic\")\n",
    "cvs = [cv for w in rotokas_words for cv in re.findall(r\"[ptksvr][aeiou]\", w)]\n",
    "print (cvs[:10])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "    a   e   i   o   u \n",
      "k 418 148  94 420 173 \n",
      "p  83  31 105  34  51 \n",
      "r 187  63  84  89  79 \n",
      "s   0   0 100   2   1 \n",
      "t  47   8   0 148  37 \n",
      "v  93  27 105  48  49 \n"
     ]
    }
   ],
   "source": [
    "cfd = nltk.ConditionalFreqDist(cvs)\n",
    "cfd.tabulate()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 5、辅音-元音对的单词的列表"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['kasuari'] \n",
      "\n",
      " ['kaapo', 'kaapopato', 'kaipori', 'kaiporipie', 'kaiporivira', 'kapo', 'kapoa', 'kapokao', 'kapokapo', 'kapokapo', 'kapokapoa', 'kapokapoa', 'kapokapora', 'kapokapora', 'kapokaporo', 'kapokaporo', 'kapokari', 'kapokarito', 'kapokoa', 'kapoo', 'kapooto', 'kapoovira', 'kapopaa', 'kaporo', 'kaporo', 'kaporopa', 'kaporoto', 'kapoto', 'karokaropo', 'karopo', 'kepo', 'kepoi', 'keposi', 'kepoto']\n"
     ]
    }
   ],
   "source": [
    "cv_word_pairs = [(cv, w) for w in rotokas_words for cv in re.findall(r\"[ptksvr][aeiou]\", w)]\n",
    "cv_index = nltk.Index(cv_word_pairs)\n",
    "print(cv_index[\"su\"],\"\\n\\n\",cv_index[\"po\"])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "这段代码依次处理每个词w，对每一个词找出匹配正则表达式«[ptksvr][aeiou]»的所有子字符串。对于词kasuari，它找到ka, su和ri。因此，cv_word_pairs将包含('ka', 'kasuari'), ('su', 'kasuari')和('ri', 'kasuari')。更进一步使用nltk.Index()转换成有用的索引。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 6、查找词干"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [],
   "source": [
    "def stem(word):\n",
    "    for suffix in ['ing', 'ly', 'ed', 'ious', 'ies', 'ive', 'es', 's', 'ment']:\n",
    "        if word.endswith(suffix):\n",
    "            return word[:-len(suffix)]\n",
    "    return word"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['ing']"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "re.findall(r\"^.*(ing|ly|ed|ious|ies|ive|es|s|ment)$\", \"processing\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['processing']"
      ]
     },
     "execution_count": 75,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "re.findall(r\"^.*(?:ing|ly|ed|ious|ies|ive|es|s|ment)$\", \"processing\")  # (?:) 表示返回匹配到的字符串，而不是匹配到的部分片段"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('process', 'ing')]"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "re.findall(r\"^(.*)(ing|ly|ed|ious|ies|ive|es|s|ment)$\", \"processing\") # (.*) 表示两个部分分别提取出来 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('processe', 's')]"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "re.findall(r'^(.*)(ing|ly|ed|ious|ies|ive|es|s|ment)$', 'processes')   # (.*) 表示贪婪提取"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('process', 'ing')]"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "re.findall(r\"^(.*?)(ing|ly|ed|ious|ies|ive|es|s|ment)$\", \"processing\") # (.*?) 添加一个 *? 号表示非贪婪提取"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('language', '')]"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "re.findall(r'^(.*?)(ing|ly|ed|ious|ies|ive|es|s|ment)?$', 'language') # 后边添加？表示可选提取"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['DENNIS', ':', 'Listen', ',', 'strange', 'women', 'ly', 'in', 'pond', 'distribut', 'sword', 'i', 'no', 'basi', 'for', 'a', 'system', 'of', 'govern', '.', 'Supreme', 'execut', 'power', 'deriv', 'from', 'a', 'mandate', 'from', 'the', 'mass', ',', 'not', 'from', 'some', 'farcical', 'aquatic', 'ceremony', '.'] \n",
      "\n",
      " ['DENNIS', ':', 'Listen', ',', 'strange', 'women', 'ly', 'in', 'pond', 'distribut', 'sword', 'i', 'no', 'basi', 'for', 'a', 'system', 'of', 'govern', '.', 'Supreme', 'execut', 'power', 'deriv', 'from', 'a', 'mandate', 'from', 'the', 'mass', ',', 'not', 'from', 'some', 'farcical', 'aquatic', 'ceremony', '.']\n"
     ]
    }
   ],
   "source": [
    "def stem2(word):\n",
    "    regexp  = r'^(.*?)(ing|ly|ed|ious|ies|ive|es|s|ment)?$'\n",
    "    stem, suffix = re.findall(regexp, word)[0]\n",
    "    return stem\n",
    "raw = \"\"\"DENNIS: Listen, strange women lying in ponds distributing swords\n",
    " is no basis for a system of government.  Supreme executive power derives from\n",
    " a mandate from the masses, not from some farcical aquatic ceremony.\"\"\"\n",
    "tokens = word_tokenize(raw)\n",
    "print([stem(t) for t in tokens],\"\\n\\n\",[stem2(t) for t in tokens])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7、使用nltk.findall搜索已分词文本\n",
    "你可以使用一种特殊的正则表达式搜索一个文本中多个词（这里的文本是一个词符列表）。例如，\"<a > <man>\" 找出文本中所有a man的实例。\n",
    "    \n",
    " 尖括号用于标记词符的边界，尖括号之间的所有空白都被忽略（这只对NLTK中的findall()方法处理文本有效）。\n",
    " \n",
    " 在下面的例子中，我们使用<.*>[1]，它将匹配所有单个词符，将它括在括号里，于是只匹配词（例如monied）而不匹配短语（例如，a monied man）会生成。\n",
    " \n",
    " 第二个例子找出以词bro结尾的三个词组成的短语[2]。\n",
    " \n",
    " 最后一个例子找出以字母l开始的三个或更多词组成的序列[3]。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['[', 'Moby', 'Dick', 'by', 'Herman', 'Melville', '1851', ']', 'ETYMOLOGY', '.'] \n",
      "\n",
      "a monied man; a nervous man; a dangerous man; a white man; a white\n",
      "man; a white man; a pious man; a queer man; a good man; a mature man;\n",
      "a white man; a Cape man; a great man; a wise man; a wise man; a\n",
      "butterless man; a white man; a fiendish man; a pale man; a furious\n",
      "man; a better man; a certain man; a complete man; a dismasted man; a\n",
      "younger man; a brave man; a brave man; a brave man; a brave man\n",
      "None \n",
      "\n",
      "monied; nervous; dangerous; white; white; white; pious; queer; good;\n",
      "mature; white; Cape; great; wise; wise; butterless; white; fiendish;\n",
      "pale; furious; better; certain; complete; dismasted; younger; brave;\n",
      "brave; brave; brave\n",
      "None\n"
     ]
    }
   ],
   "source": [
    "from nltk.corpus import gutenberg, nps_chat\n",
    "moby = nltk.Text(gutenberg.words(\"melville-moby_dick.txt\"))\n",
    "print(moby[:10],\"\\n\")\n",
    "print(moby.findall(r\"<a><.*><man>\"),\"\\n\")\n",
    "print(moby.findall(r\"<a>(<.*>)<man>\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['now', 'im', 'left', 'with', 'this', 'gay', 'name', ':P', 'PART', 'hey'] \n",
      "\n",
      "you rule bro; telling you bro; u twizted bro\n"
     ]
    }
   ],
   "source": [
    "chat = nltk.Text(nps_chat.words())\n",
    "print(chat[:10],\"\\n\")\n",
    "chat.findall(r\"<.*><.*><bro>\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "lol lol lol; lmao lol lol; lol lol lol; la la la la la; la la la; la\n",
      "la la; lovely lol lol love; lol lol lol.; la la la; la la la\n"
     ]
    }
   ],
   "source": [
    "chat.findall(r\"<l.*>{3,}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "123{asd}456\n"
     ]
    }
   ],
   "source": [
    "p=r'[a-zA-Z]+'\n",
    "nltk.re_show(p,'123asd456')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 8、在大型文本语料库中搜索x and other ys形式的表达式"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "speed and other activities; water and other liquids; tomb and other\n",
      "landmarks; Statues and other monuments; pearls and other jewels;\n",
      "charts and other items; roads and other features; figures and other\n",
      "objects; military and other areas; demands and other factors;\n",
      "abstracts and other compilations; iron and other metals\n"
     ]
    }
   ],
   "source": [
    "from nltk.corpus import brown\n",
    "hobbies_learned = nltk.Text(brown.words(categories = [\"hobbies\", \"learned\"]))\n",
    "hobbies_learned.findall(r\"<\\w*><and><other><\\w*s>\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "as accurately as possible; as well as the; as faithfully as possible;\n",
      "as much as what; as neat as a; as simple as you; as well as other; as\n",
      "well as other; as involved as determining; as well as other; as\n",
      "important as another; as accurately as possible; as accurate as any;\n",
      "as much as any; as different as a; as Orphic as that; as coppery as\n",
      "Delawares; as good as another; as large as small; as well as ease; as\n",
      "well as their; as well as possible; as straight as possible; as well\n",
      "as nailed; as smoothly as the; as soon as a; as well as injuries; as\n",
      "well as many; as well as reason; as well as in; as well as of; as well\n",
      "as a; as well as summer; as well as providing; as important as\n",
      "cooling; as evenly as it; as much as shading; as well as some; as well\n",
      "as subsoil; as high as possible; as well as many; as general as\n",
      "electrical; as long as the; as well as the; as much as was; as well as\n",
      "set; as well as by; as high as 15; as well as aid; as much as\n",
      "possible; as well as personalities; as low as a; as well as the; as\n",
      "much as glass; as popular as renting; as expensive as most; as well as\n",
      "relative; as well as by; as well as the; as far as possible; as far as\n",
      "radiation; as well as theoretical; as well as nuclear; as small as\n",
      "possible; as well as soap; as effective as the; as much as\n",
      "approximately; as well as information; as little as one; as much as\n",
      "an; as low as Af; as long as the; as far as possible; as well as\n",
      "their; as well as Hand; as well as all; as well as fractionation; as\n",
      "potent as the; as well as fever; as large as 3; as well as varying; as\n",
      "well as the; as long as 2; as far as emotional; as well as the; as\n",
      "well as regarding; as well as enthusiasm; as well as by; as well as\n",
      "her; as well as a; as old as social; as well as the; as well as the;\n",
      "as well as in; as much as they; as much as possible; as well as the;\n",
      "as well as some; as simple as one; as well as the; as well as in; as\n",
      "definable as possible; as long as they; as well as their; as well as\n",
      "forecasting; as soon as possible; as inevitable as anything; as well\n",
      "as for; as well as for; as nebulous as the; as awkward as the; as well\n",
      "as the; as well as by; as well as those; as well as the; as well as\n",
      "an; as well as with; as well as the; as well as moral; as much as\n",
      "their; as well as that; as likely as not; as well as upon; as well as\n",
      "on; as well as upon; as long as all; as far as one; as long as the; as\n",
      "empty as the; as well as the; as well as the; as soon as they; as well\n",
      "as office; as speedily as possible; as well as of; as well as start;\n",
      "as well as behind; as much as for; as effectively as they; as\n",
      "important as it; as nearly as feasible; as well as form; as well as\n",
      "aesthetic; as well as ethical; as well as Impressionism; as well as\n",
      "the; as broad as the; as much as he; as arresting as a; as odd as the;\n",
      "as well as the; as soon as possible; as long as it; as impassive as\n",
      "Persian; as long as those; as importantly as his; as well as\n",
      "providing; as well as the; as well as vertically; as well as new; as\n",
      "well as certain; as well as the; as close as possible; as far as\n",
      "obtainable; as well as the; as important as the; as long as the; as\n",
      "satisfactory as those\n"
     ]
    }
   ],
   "source": [
    "hobbies_learned.findall(r\"<as><\\w*><as><\\w*>\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 3.6 规范化文本"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['DENNIS', ':', 'Listen', ',', 'strange', 'women', 'lying', 'in', 'ponds', 'distributing', 'swords', 'is', 'no', 'basis', 'for', 'a', 'system', 'of', 'government', '.', 'Supreme', 'executive', 'power', 'derives', 'from', 'a', 'mandate', 'from', 'the', 'masses', ',', 'not', 'from', 'some', 'farcical', 'aquatic', 'ceremony', '.']\n"
     ]
    }
   ],
   "source": [
    "raw = \"\"\"DENNIS: Listen, strange women lying in ponds distributing swords\n",
    "... is no basis for a system of government.  Supreme executive power derives from\n",
    "... a mandate from the masses, not from some farcical aquatic ceremony.\"\"\"\n",
    "tokens = word_tokenize(raw)\n",
    "print(tokens)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1、词干提取器\n",
    "看Porter词干提取器正确处理了词lying（将它映射为lie），而Lancaster词干提取器并没有处理好。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['denni', ':', 'listen', ',', 'strang', 'women', 'lie', 'in', 'pond', 'distribut', 'sword', 'is', 'no', 'basi', 'for', 'a', 'system', 'of', 'govern', '.', 'suprem', 'execut', 'power', 'deriv', 'from', 'a', 'mandat', 'from', 'the', 'mass', ',', 'not', 'from', 'some', 'farcic', 'aquat', 'ceremoni', '.']\n"
     ]
    }
   ],
   "source": [
    "porter = nltk.PorterStemmer()\n",
    "print([porter.stem(t) for t in tokens])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['den', ':', 'list', ',', 'strange', 'wom', 'lying', 'in', 'pond', 'distribut', 'sword', 'is', 'no', 'bas', 'for', 'a', 'system', 'of', 'govern', '.', 'suprem', 'execut', 'pow', 'der', 'from', 'a', 'mand', 'from', 'the', 'mass', ',', 'not', 'from', 'som', 'farc', 'aqu', 'ceremony', '.']\n"
     ]
    }
   ],
   "source": [
    "lancaster = nltk.LancasterStemmer()\n",
    "print([lancaster.stem(t) for t in tokens])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2、词形归并\n",
    "WordNet词形归并器只在产生的词在它的词典中时才删除词缀。这个额外的检查过程使词形归并器比刚才提到的词干提取器要慢。请注意，它并没有处理lying，但它将women转换为woman。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['DENNIS', ':', 'Listen', ',', 'strange', 'woman', 'lying', 'in', 'pond', 'distributing', 'sword', 'is', 'no', 'basis', 'for', 'a', 'system', 'of', 'government', '.', 'Supreme', 'executive', 'power', 'derives', 'from', 'a', 'mandate', 'from', 'the', 'mass', ',', 'not', 'from', 'some', 'farcical', 'aquatic', 'ceremony', '.']\n"
     ]
    }
   ],
   "source": [
    "wnl = nltk.WordNetLemmatizer()\n",
    "print([wnl.lemmatize(t) for t in tokens])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 3.7 用正则表达式为文本分词"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1、分词的简单方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[\"'When\", \"I'M\", 'a', \"Duchess,'\", 'she', 'said', 'to', 'herself,', '(not', 'in', 'a', 'very', 'hopeful', 'tone\\nthough),', \"'I\", \"won't\", 'have', 'any', 'pepper', 'in', 'my', 'kitchen', 'AT', 'ALL.', 'Soup', 'does', 'very\\nwell', 'without--Maybe', \"it's\", 'always', 'pepper', 'that', 'makes', 'people', \"hot-tempered,'...\"]\n"
     ]
    }
   ],
   "source": [
    "raw = \"\"\"'When I'M a Duchess,' she said to herself, (not in a very hopeful tone\n",
    "though), 'I won't have any pepper in my kitchen AT ALL. Soup does very\n",
    "well without--Maybe it's always pepper that makes people hot-tempered,'...\"\"\"\n",
    "print(re.split(r\" \", raw)) # 在 空格字符 处分割原始文本"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[\"'When\", \"I'M\", 'a', \"Duchess,'\", 'she', 'said', 'to', 'herself,', '(not', 'in', 'a', 'very', 'hopeful', 'tone', 'though),', \"'I\", \"won't\", 'have', 'any', 'pepper', 'in', 'my', 'kitchen', 'AT', 'ALL.', 'Soup', 'does', 'very', 'well', 'without--Maybe', \"it's\", 'always', 'pepper', 'that', 'makes', 'people', \"hot-tempered,'...\"]\n"
     ]
    }
   ],
   "source": [
    "print(re.split(r\"[ \\t\\n]+\",raw)) # 在 空格 或 制表符（\\t） 或 换行符（\\n） 处分割原始文本"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[\"'When\", \"I'M\", 'a', \"Duchess,'\", 'she', 'said', 'to', 'herself,', '(not', 'in', 'a', 'very', 'hopeful', 'tone', 'though),', \"'I\", \"won't\", 'have', 'any', 'pepper', 'in', 'my', 'kitchen', 'AT', 'ALL.', 'Soup', 'does', 'very', 'well', 'without--Maybe', \"it's\", 'always', 'pepper', 'that', 'makes', 'people', \"hot-tempered,'...\"]\n"
     ]
    }
   ],
   "source": [
    "print(re.split(r\"\\s+\", raw)) # 在 所有空白字符 处分割原始文本"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['', 'When', 'I', 'M', 'a', 'Duchess', 'she', 'said', 'to', 'herself', 'not', 'in', 'a', 'very', 'hopeful', 'tone', 'though', 'I', 'won', 't', 'have', 'any', 'pepper', 'in', 'my', 'kitchen', 'AT', 'ALL', 'Soup', 'does', 'very', 'well', 'without', 'Maybe', 'it', 's', 'always', 'pepper', 'that', 'makes', 'people', 'hot', 'tempered', '']\n"
     ]
    }
   ],
   "source": [
    "print(re.split(r\"\\W+\", raw)) # 在 \\w 的补集处分割原始文本 ； \\w 表示匹配所有字符，相当于[a-zA-Z0-9_] ; \\W 表示 \\w 的补集，即所有字母数字下划线以外的字符"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[\"'When\", 'I', \"'M\", 'a', 'Duchess', ',', \"'\", 'she', 'said', 'to', 'herself', ',', '(not', 'in', 'a', 'very', 'hopeful', 'tone', 'though', ')', ',', \"'I\", 'won', \"'t\", 'have', 'any', 'pepper', 'in', 'my', 'kitchen', 'AT', 'ALL', '.', 'Soup', 'does', 'very', 'well', 'without', '-', '-Maybe', 'it', \"'s\", 'always', 'pepper', 'that', 'makes', 'people', 'hot', '-tempered', ',', \"'\", '.', '.', '.']\n"
     ]
    }
   ],
   "source": [
    "print(re.findall(r\"\\w+|\\S\\w*\", raw))  # 首先匹配字母数字下划线，如果没有则匹配非空白字符（\\S 是\\s 的补集）加上字母数字下划线"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 121,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[\"'\", 'When', \"I'M\", 'a', 'Duchess', ',', \"'\", 'she', 'said', 'to', 'herself', ',', '(', 'not', 'in', 'a', 'very', 'hopeful', 'tone', 'though', ')', ',', \"'\", 'I', \"won't\", 'have', 'any', 'pepper', 'in', 'my', 'kitchen', 'AT', 'ALL', '.', 'Soup', 'does', 'very', 'well', 'without', '--', 'Maybe', \"it's\", 'always', 'pepper', 'that', 'makes', 'people', 'hot-tempered', ',', \"'\", '...']\n"
     ]
    }
   ],
   "source": [
    "print(re.findall(r\"\\w+(?:[-']\\w+)*|'|[-.(]+|\\S\\w*\", raw))  # \\w+(?:[-']\\w+)* 会匹配 hot-tempered和it's"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2、nltk自带的正则匹配"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 3.8 分割"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1、断句"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 129,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "20.250994070456922"
      ]
     },
     "execution_count": 129,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(nltk.corpus.brown.words()) / len(nltk.corpus.brown.sents()) # 计算布朗语料库中每个句子的平均词数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 131,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['\"Nonsense!\"',\n",
      " 'said Gregory, who was very rational when anyone else\\nattempted paradox.',\n",
      " '\"Why do all the clerks and navvies in the\\n'\n",
      " 'railway trains look so sad and tired, so very sad and tired?',\n",
      " 'I will\\ntell you.',\n",
      " 'It is because they know that the train is going right.',\n",
      " 'It\\n'\n",
      " 'is because they know that whatever place they have taken a ticket\\n'\n",
      " 'for that place they will reach.',\n",
      " 'It is because after they have\\n'\n",
      " 'passed Sloane Square they know that the next station must be\\n'\n",
      " 'Victoria, and nothing but Victoria.',\n",
      " 'Oh, their wild rapture!',\n",
      " 'oh,\\n'\n",
      " 'their eyes like stars and their souls again in Eden, if the next\\n'\n",
      " 'station were unaccountably Baker Street!\"',\n",
      " '\"It is you who are unpoetical,\" replied the poet Syme.']\n"
     ]
    }
   ],
   "source": [
    "# 使用nltk自带的Punkt句子分割器为一篇小说文本断句\n",
    "text = nltk.corpus.gutenberg.raw(\"chesterton-thursday.txt\")\n",
    "sents = nltk.sent_tokenize(text)\n",
    "pprint.pprint(sents[79:89])          # pprint()模块打印出来的数据结构更加完整，每行为一个数据结构，更加方便阅读打印输出结果"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2、分词\n",
    "类似的问题在口语语言处理中也会出现，听者必须将连续的语音流分割成单个的词汇。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 141,
   "metadata": {},
   "outputs": [],
   "source": [
    ">>> text = \"doyouseethekittyseethedoggydoyoulikethekittylikethedoggy\"\n",
    ">>> seg1 = \"0000000000000001000000000010000000000000000100000000000\"\n",
    ">>> seg2 = \"0100100100100001001001000010100100010010000100010010000\"\n",
    "seg3 = \"0000100100000011001000000110000100010000001100010000001\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 142,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['doyouseethekitty', 'seethedoggy', 'doyoulikethekitty', 'likethedoggy']\n",
      "['do', 'you', 'see', 'the', 'kitty', 'see', 'the', 'doggy', 'do', 'you', 'like', 'the', 'kitty', 'like', 'the', 'doggy']\n",
      "['doyou', 'see', 'thekitt', 'y', 'see', 'thedogg', 'y', 'doyou', 'like', 'thekitt', 'y', 'like', 'thedogg', 'y']\n"
     ]
    }
   ],
   "source": [
    "def segment(text, segs):\n",
    "    words = []\n",
    "    last = 0\n",
    "    for i in range(len(segs)):\n",
    "        if segs[i] == \"1\":\n",
    "            words.append(text[last:i+1])\n",
    "            last = i + 1\n",
    "    words.append(text[last:])\n",
    "    return words\n",
    "print(segment(text,seg1))\n",
    "print(segment(text,seg2))\n",
    "print(segment(text,seg3))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "计算目标函数：给定一个假设的源文本的分词（左），推导出一个词典和推导表，它能让源文本重构，然后合计每个词项（包括边界标志）与推导表的字符数，作为分词质量的得分；得分值越小表明分词越好。\n",
    "\n",
    "![3.3](./picture/3.3.png)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 143,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "64\n",
      "48\n",
      "47\n"
     ]
    }
   ],
   "source": [
    "def evaluate(text, segs):\n",
    "    words = segment(text, segs)\n",
    "    text_size = len(words)\n",
    "    lexicon_size = sum(len(word) + 1 for word in set(words))\n",
    "    return text_size + lexicon_size\n",
    "print(evaluate(text, seg1))\n",
    "print(evaluate(text, seg2))\n",
    "print(evaluate(text, seg3))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "例 3-4. 使用模拟退火算法的非确定性搜索:一开始仅搜索短语分词;随机扰动 0 和 1,\n",
    "它们与“温度”成比例;每次迭代温度都会降低,扰动边界会减少。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 148,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "64 ['doyouseethekitty', 'seethedoggy', 'doyoulikethekitty', 'likethedoggy']\n",
      "64 ['doyouseethekitty', 'seethedoggy', 'doyoulikethekitty', 'likethedoggy']\n",
      "64 ['doyouseethekitty', 'seethedoggy', 'doyoulikethekitty', 'likethedoggy']\n",
      "64 ['doyouseethekitty', 'seethedoggy', 'doyoulikethekitty', 'likethedoggy']\n",
      "64 ['doyouseethekitty', 'seethedoggy', 'doyoulikethekitty', 'likethedoggy']\n",
      "63 ['do', 'y', 'ousee', 'thekitt', 'y', 'see', 'thedoggy', 'doy', 'oulike', 'thekitt', 'y', 'li', 'ke', 'thedoggy']\n",
      "63 ['do', 'y', 'ousee', 'thekitt', 'y', 'see', 'thedoggy', 'doy', 'oulike', 'thekitt', 'y', 'li', 'ke', 'thedoggy']\n",
      "63 ['do', 'y', 'ousee', 'thekitt', 'y', 'see', 'thedoggy', 'doy', 'oulike', 'thekitt', 'y', 'li', 'ke', 'thedoggy']\n",
      "63 ['do', 'y', 'ousee', 'thekitt', 'y', 'see', 'thedoggy', 'doy', 'oulike', 'thekitt', 'y', 'li', 'ke', 'thedoggy']\n",
      "63 ['do', 'y', 'ousee', 'thekitt', 'y', 'see', 'thedoggy', 'doy', 'oulike', 'thekitt', 'y', 'li', 'ke', 'thedoggy']\n",
      "59 ['do', 'you', 'see', 'thekitt', 'y', 'see', 'thedoggy', 'doy', 'oulike', 'thekitt', 'y', 'like', 'thedoggy']\n",
      "57 ['doyou', 'see', 'thekitt', 'y', 'see', 'thedoggy', 'doy', 'oulike', 'thekitt', 'y', 'like', 'thedoggy']\n",
      "52 ['doyou', 'see', 'the', 'k', 'itt', 'y', 'see', 'thedoggy', 'doyou', 'like', 'the', 'k', 'itt', 'y', 'like', 'thedoggy']\n",
      "52 ['doyou', 'see', 'the', 'k', 'itt', 'y', 'see', 'thedoggy', 'doyou', 'like', 'the', 'k', 'itt', 'y', 'like', 'thedoggy']\n",
      "49 ['doyou', 'see', 'the', 'kitt', 'y', 'see', 'thedoggy', 'doyou', 'like', 'the', 'kitt', 'y', 'like', 'thedoggy']\n",
      "49 ['doyou', 'see', 'the', 'kitt', 'y', 'see', 'thedoggy', 'doyou', 'like', 'the', 'kitt', 'y', 'like', 'thedoggy']\n",
      "49 ['doyou', 'see', 'the', 'kitt', 'y', 'see', 'thedoggy', 'doyou', 'like', 'the', 'kitt', 'y', 'like', 'thedoggy']\n",
      "46 ['doyou', 'see', 'thekitt', 'y', 'see', 'thedoggy', 'doyou', 'like', 'thekitt', 'y', 'like', 'thedoggy']\n",
      "43 ['doyou', 'see', 'thekitty', 'see', 'thedoggy', 'doyou', 'like', 'thekitty', 'like', 'thedoggy']\n",
      "43 ['doyou', 'see', 'thekitty', 'see', 'thedoggy', 'doyou', 'like', 'thekitty', 'like', 'thedoggy']\n",
      "43 ['doyou', 'see', 'thekitty', 'see', 'thedoggy', 'doyou', 'like', 'thekitty', 'like', 'thedoggy']\n",
      "43 ['doyou', 'see', 'thekitty', 'see', 'thedoggy', 'doyou', 'like', 'thekitty', 'like', 'thedoggy']\n",
      "43 ['doyou', 'see', 'thekitty', 'see', 'thedoggy', 'doyou', 'like', 'thekitty', 'like', 'thedoggy']\n",
      "43 ['doyou', 'see', 'thekitty', 'see', 'thedoggy', 'doyou', 'like', 'thekitty', 'like', 'thedoggy']\n",
      "43 ['doyou', 'see', 'thekitty', 'see', 'thedoggy', 'doyou', 'like', 'thekitty', 'like', 'thedoggy']\n",
      "43 ['doyou', 'see', 'thekitty', 'see', 'thedoggy', 'doyou', 'like', 'thekitty', 'like', 'thedoggy']\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'0000100100000001001000000010000100010000000100010000000'"
      ]
     },
     "execution_count": 148,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from random import randint\n",
    "\n",
    "def flip(segs, pos):\n",
    "    return segs[:pos] + str(1-int(segs[pos])) + segs[pos+1:]  # 将segs中pos位置的数字翻转：1变0 ; 0变1\n",
    "\n",
    "def flip_n(segs, n):\n",
    "    for i in range(n):\n",
    "        segs = flip(segs, randint(0,len(segs)-1))                        # 随机翻转segs中的0或者1 n次\n",
    "    return segs\n",
    "\n",
    "def anneal(text, segs, iterations, cooling_rate):\n",
    "    temperature = float(len(segs))\n",
    "    while temperature > 0.5:\n",
    "        best_segs, best = segs, evaluate(text, segs)\n",
    "        for i in range(iterations):\n",
    "            guess = flip_n(segs, int(round(temperature)))  # round 返回浮点数的四舍五入   \n",
    "            score = evaluate(text, guess)\n",
    "            if score < best:\n",
    "                best, best_segs = score, guess\n",
    "        score, segs = best, best_segs\n",
    "        temperature = temperature / cooling_rate\n",
    "        print (evaluate(text, segs), segment(text, segs))\n",
    "    print\n",
    "    return segs\n",
    "\n",
    "text = \"doyouseethekittyseethedoggydoyoulikethekittylikethedoggy\"\n",
    "\n",
    "seg1 = \"0000000000000001000000000010000000000000000100000000000\"\n",
    "\n",
    "anneal(text, seg1, 5000, 1.2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "有了足够的数据,就可能以一个合理的准确度自动将文本分割成词汇。这种方法可用于\n",
    "为那些词的边界没有任何视觉表示的书写系统分词。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 3.9 格式化：从列表到字符串"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1、从列表到字符串"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 149,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "We called him Tortoise because he taught us .\n"
     ]
    }
   ],
   "source": [
    "silly = ['We', 'called', 'him', 'Tortoise', 'because', 'he', 'taught', 'us', '.']\n",
    "print(\" \".join(silly))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1、字符串与格式\n",
    "我们已经看到了有两种方式显示一个对象的内容："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 151,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "cat\n",
      "\n",
      "hello\n",
      "word\n",
      "\n"
     ]
    }
   ],
   "source": [
    "word = \"cat\"\n",
    "sentence = \"\"\"\n",
    "hello\n",
    "word\n",
    "\"\"\"\n",
    "print(word)\n",
    "print(sentence)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "print命令让Python努力以人最可读的形式输出的一个对象的内容。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 152,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'cat'"
      ]
     },
     "execution_count": 152,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "word"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 153,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'\\nhello\\nword\\n'"
      ]
     },
     "execution_count": 153,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sentence"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "第二种方法——叫做变量提示——向我们显示可用于重新创建该对象的字符串。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2、格式化输出"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 154,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dog -> 4;cat -> 3;snake -> 1;"
     ]
    }
   ],
   "source": [
    "# 1.变量和常量交替出现\n",
    "fdist = nltk.FreqDist(['dog', 'cat', 'dog', 'cat', 'dog', 'snake', 'dog', 'cat'])\n",
    "for word in fdist:\n",
    "    print(word, \"->\", fdist[word], end = \";\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 155,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dog->4; cat->3; snake->1; "
     ]
    }
   ],
   "source": [
    "# 2.使用str.format（）方法\n",
    "fdist = nltk.FreqDist(['dog', 'cat', 'dog', 'cat', 'dog', 'snake', 'dog', 'cat'])\n",
    "for word in fdist:\n",
    "    print(\"{}->{};\".format(word, fdist[word]), end = ' ')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3、使用str.format（）方法对齐"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 160,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'    41'"
      ]
     },
     "execution_count": 160,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"{:6}\".format(41)   # 字符宽度为6，数字默认右对齐"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 161,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'41    '"
      ]
     },
     "execution_count": 161,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"{:<6}\".format(41)   # 字符宽度为6，数字 < 表示左对齐"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 163,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'dog   '"
      ]
     },
     "execution_count": 163,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"{:6}\".format(\"dog\") # 字符宽度为6，字符默认左对齐"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 167,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'   dog'"
      ]
     },
     "execution_count": 167,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"{:>6}\".format(\"dog\") # 字符宽度为6，字符 > 表示左对齐 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 168,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'3.1416'"
      ]
     },
     "execution_count": 168,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 指定浮点数的符号和精度\n",
    "import math\n",
    "\"{:.4f}\".format(math.pi)  # 表示小数点后边显示4位"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 169,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'accuracy for 9375 words: 34.1867%'"
      ]
     },
     "execution_count": 169,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 表示百分数\n",
    "\"accuracy for {} words: {:.4%}\".format(9375, 3205 / 9375)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 4、格式化字符串用于数据制表"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 175,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Category                can  could    may  might   must   will \n",
      "news                     93     86     66     38     50    389 \n",
      "religion                 82     59     78     12     54     71 \n",
      "hobbies                 268     58    131     22     83    264 \n",
      "science_fiction          16     49      4     12      8     16 \n",
      "romance                  74    193     11     51     45     43 \n",
      "humor                    16     30      8      8      9     13 \n"
     ]
    }
   ],
   "source": [
    "def tabulate(cfdist, words, categories):\n",
    "    print(\"{:20}\".format(\"Category\"), end = \" \")\n",
    "    for word in words:\n",
    "        print(\"{:>6}\".format(word), end = \" \")\n",
    "    print ()\n",
    "    for category in categories:\n",
    "        print(\"{:20}\".format(category), end = \" \")\n",
    "        for word in words:\n",
    "            print(\"{:6}\".format(cfdist[category][word]), end = \" \")\n",
    "        print()\n",
    "        \n",
    "from nltk.corpus import brown\n",
    "\n",
    "cfd = nltk.ConditionalFreqDist(\n",
    "    (genre, word) \n",
    "    for genre in brown.categories() \n",
    "    for word in brown.words(categories = genre))\n",
    "\n",
    "genres = ['news', 'religion', 'hobbies', 'science_fiction', 'romance', 'humor']\n",
    "modals = ['can', 'could', 'may', 'might', 'must', 'will']\n",
    "\n",
    "tabulate(cfd, modals, genres)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 183,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Monty Python   '"
      ]
     },
     "execution_count": 183,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 自动定制列的宽度\n",
    "#width = max(len(w) for w in words)\n",
    "\"{:{width}}\".format(\"Monty Python\", width = 15)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 5、将结果写入文件"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 185,
   "metadata": {},
   "outputs": [],
   "source": [
    "output_file = open(\"3.output.txt\", \"w\")\n",
    "words = set(nltk.corpus.genesis.words(\"english-kjv.txt\"))\n",
    "for word in sorted(words):\n",
    "    print(word, file = output_file)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 187,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 当我们将非文本数据写入文件时，我们必须先将它转换为字符串。\n",
    "print(str(len(words)), file = output_file)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 6、文本换行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 188,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "After (5) ,  all (3) ,  is (2) ,  said (4) ,  and (3) ,  done (4) ,  , (1) ,  more (4) ,  is (2) ,  said (4) ,  than (4) ,  done (4) ,  . (1) ,  "
     ]
    }
   ],
   "source": [
    "saying = ['After', 'all', 'is', 'said', 'and', 'done', ',',\n",
    "         'more', 'is', 'said', 'than', 'done', '.']\n",
    "for word in saying:\n",
    "    print(word, \"(\" + str(len(word)) + \") , \", end = \" \")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "我们可以在Python 的textwrap模块的帮助下采取换行。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 190,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "After (5) ,  all (3) ,  is (2) ,  said (4) ,  and (3) ,  done (4) ,  , (1) ,  more (4) ,  is (2) ,  said (4) ,  than (4) ,  done (4) ,  . (1) ,  \n",
      "\n",
      "After (5) ,  all (3) ,  is (2) ,  said (4) ,  and (3) ,  done (4) ,  ,\n",
      "(1) ,  more (4) ,  is (2) ,  said (4) ,  than (4) ,  done (4) ,  . (1)\n",
      ",\n"
     ]
    }
   ],
   "source": [
    "from textwrap import fill\n",
    "format = \"%s (%d) , \"\n",
    "pieces = [format % (word, len(word)) for word in saying]\n",
    "output = \" \".join(pieces)\n",
    "print(output,\"\\n\")\n",
    "print(fill(output))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
